コード例 #1
0
ファイル: Vec3.cs プロジェクト: lin5/UnityMathReference
        public Vec3 RotateAround(Vec3 axis, float angle)
        {
            // rotate into world space
            var quaternion = Quat.FromRotationAxis(axis, 0);

            quaternion = quaternion.Conjugate();
            var worldSpaceVector = this.Transform(quaternion);

            // rotate back to vector space
            quaternion       = Quat.FromRotationAxis(axis, angle);
            worldSpaceVector = worldSpaceVector.Transform(quaternion);
            return(worldSpaceVector);
        }
コード例 #2
0
        public Mat3 RotateAround(Vec3 axis, float angle)
        {
            // rotate into world space
            var quaternion       = Quat.FromRotationAxis(axis, 0).Conjugate();
            var worldSpaceMatrix = this.Multiply(FromQuaternion(quaternion));

            // rotate back to matrix space
            quaternion = Quat.FromRotationAxis(axis, angle);
            var qMat = Mat3.FromQuaternion(quaternion);

            worldSpaceMatrix = worldSpaceMatrix.Multiply(qMat);
            return(worldSpaceMatrix);
        }
コード例 #3
0
        public Mat4 FromRotationAxis(Vec3 axis, float angle)
        {
            Quat quaternion = Quat.FromRotationAxis(axis, angle);

            return(Mat4.FromQuaternion(quaternion));
        }