| 703 | } |
| 704 | |
| 705 | void Matrix::Transformation(const Float3& scaling, const Quaternion& rotation, const Float3& translation, Matrix& result) |
| 706 | { |
| 707 | // Equivalent to: |
| 708 | //result = |
| 709 | // Matrix.Scaling(scaling) |
| 710 | // *Matrix.RotationX(rotation.X) |
| 711 | // *Matrix.RotationY(rotation.Y) |
| 712 | // *Matrix.RotationZ(rotation.Z) |
| 713 | // *Matrix.Position(translation); |
| 714 | |
| 715 | // Rotation |
| 716 | const float xx = rotation.X * rotation.X; |
| 717 | const float yy = rotation.Y * rotation.Y; |
| 718 | const float zz = rotation.Z * rotation.Z; |
| 719 | const float xy = rotation.X * rotation.Y; |
| 720 | const float zw = rotation.Z * rotation.W; |
| 721 | const float zx = rotation.Z * rotation.X; |
| 722 | const float yw = rotation.Y * rotation.W; |
| 723 | const float yz = rotation.Y * rotation.Z; |
| 724 | const float xw = rotation.X * rotation.W; |
| 725 | result.M11 = 1.0f - 2.0f * (yy + zz); |
| 726 | result.M12 = 2.0f * (xy + zw); |
| 727 | result.M13 = 2.0f * (zx - yw); |
| 728 | result.M21 = 2.0f * (xy - zw); |
| 729 | result.M22 = 1.0f - 2.0f * (zz + xx); |
| 730 | result.M23 = 2.0f * (yz + xw); |
| 731 | result.M31 = 2.0f * (zx + yw); |
| 732 | result.M32 = 2.0f * (yz - xw); |
| 733 | result.M33 = 1.0f - 2.0f * (yy + xx); |
| 734 | |
| 735 | // Position |
| 736 | result.M41 = translation.X; |
| 737 | result.M42 = translation.Y; |
| 738 | result.M43 = translation.Z; |
| 739 | |
| 740 | // Scale |
| 741 | result.M11 *= scaling.X; |
| 742 | result.M12 *= scaling.X; |
| 743 | result.M13 *= scaling.X; |
| 744 | result.M21 *= scaling.Y; |
| 745 | result.M22 *= scaling.Y; |
| 746 | result.M23 *= scaling.Y; |
| 747 | result.M31 *= scaling.Z; |
| 748 | result.M32 *= scaling.Z; |
| 749 | result.M33 *= scaling.Z; |
| 750 | |
| 751 | result.M14 = 0.0f; |
| 752 | result.M24 = 0.0f; |
| 753 | result.M34 = 0.0f; |
| 754 | result.M44 = 1.0f; |
| 755 | } |
| 756 | |
| 757 | void Matrix::AffineTransformation(float scaling, const Quaternion& rotation, const Float3& translation, Matrix& result) |
| 758 | { |
no test coverage detected