Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public Mat3 FromRotationAxis(Vec3 axis, float angle)
        {
            Quat quaternion = Quat.FromRotationAxis(axis, angle);

            return(FromQuaternion(quaternion));
        }