SetFromRotationMatrix sets this vector components to the Euler angles from the specified pure rotation matrix. Returns the pointer to this updated vector.
(m *Matrix4)
| 608 | // from the specified pure rotation matrix. |
| 609 | // Returns the pointer to this updated vector. |
| 610 | func (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 |