MCPcopy
hub / github.com/g3n/engine / SetFromRotationMatrix

Method SetFromRotationMatrix

math32/vector3.go:610–629  ·  view source on GitHub ↗

SetFromRotationMatrix sets this vector components to the Euler angles from the specified pure rotation matrix. Returns the pointer to this updated vector.

(m *Matrix4)

Source from the content-addressed store, hash-verified

608// from the specified pure rotation matrix.
609// Returns the pointer to this updated vector.
610func (v *Vector3) SetFromRotationMatrix(m *Matrix4) *Vector3 {
611
612 m11 := m[0]
613 m12 := m[4]
614 m13 := m[8]
615 m22 := m[5]
616 m23 := m[9]
617 m32 := m[6]
618 m33 := m[10]
619
620 v.Y = Asin(Clamp(m13, -1, 1))
621 if Abs(m13) < 0.99999 {
622 v.X = Atan2(-m23, m33)
623 v.Z = Atan2(-m12, m11)
624 } else {
625 v.X = Atan2(m32, m22)
626 v.Z = 0
627 }
628 return v
629}
630
631// SetFromQuaternion sets this vector components to the Euler angles
632// from the specified quaternion

Callers 3

SetFromQuaternionMethod · 0.95
DecomposeMethod · 0.45
LookAtMethod · 0.45

Calls 4

AsinFunction · 0.85
ClampFunction · 0.85
AbsFunction · 0.85
Atan2Function · 0.85

Tested by

no test coverage detected