CSharpGL.IModelSpaceHelper.Rotate C# (CSharp) Method

Rotate() public static method

Rotate this model based on all previous rotation actions. Thus all rotations will take part in model's rotation result.

在目前的旋转状态下继续旋转一次,即所有的旋转操作都会(按照发生顺序)生效。

public static Rotate ( this model, float angleDegree, vec3 axis ) : void
model this
angleDegree float Angle in Degree.
axis vec3
return void
        public static void Rotate(this IModelSpace model, float angleDegree, vec3 axis)
        {
            mat4 currentRotationMatrix = glm.rotate(model.RotationAngleDegree, model.RotationAxis);
            mat4 newRotationMatrix = glm.rotate(angleDegree, axis);
            mat4 latestRotationMatrix = newRotationMatrix * currentRotationMatrix;
            Quaternion quaternion = latestRotationMatrix.ToQuaternion();
            float latestAngle;
            vec3 latestAxis;
            quaternion.Parse(out latestAngle, out latestAxis);
            model.RotationAngleDegree = latestAngle;
            model.RotationAxis = latestAxis;
        }