Exemple #1
0
 private static Vector3D GetUnitEulerAngles(Vector3D eulerAngles)
 {
     if (eulerAngles.X >= 180.000001)
     {
         eulerAngles.X = RotateBehavior3D.Remainder(eulerAngles.X + 180.0, 360.0) - 180.0;
     }
     if (eulerAngles.Y >= 180.000001)
     {
         eulerAngles.Y = RotateBehavior3D.Remainder(eulerAngles.Y + 180.0, 360.0) - 180.0;
     }
     if (eulerAngles.Z >= 180.000001)
     {
         eulerAngles.Z = RotateBehavior3D.Remainder(eulerAngles.Z + 180.0, 360.0) - 180.0;
     }
     if (eulerAngles.X <= -180.000001)
     {
         eulerAngles.X = RotateBehavior3D.Remainder(eulerAngles.X - 180.0, 360.0) + 180.0;
     }
     if (eulerAngles.Y <= -180.000001)
     {
         eulerAngles.Y = RotateBehavior3D.Remainder(eulerAngles.Y - 180.0, 360.0) + 180.0;
     }
     if (eulerAngles.Z <= -180.000001)
     {
         eulerAngles.Z = RotateBehavior3D.Remainder(eulerAngles.Z - 180.0, 360.0) + 180.0;
     }
     return(eulerAngles);
 }
Exemple #2
0
        protected override void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta)
        {
            this.lastUnsnappedAngle += this.ActiveView.Zoom * this.mouseMovementAxis * mousePositionDelta;
            double angleInDegrees1 = this.lastUnsnappedAngle;

            if (this.ShiftKeyDepressed)
            {
                angleInDegrees1 = RotateBehavior3D.shiftSnapAngle * Math.Round(angleInDegrees1 / RotateBehavior3D.shiftSnapAngle);
            }
            double angleInDegrees2 = !this.previousAngle.HasValue ? angleInDegrees1 : angleInDegrees1 - this.previousAngle.Value;

            this.previousAngle = new double?(angleInDegrees1);
            Vector3D unitEulerAngles = RotateBehavior3D.GetUnitEulerAngles(Helper3D.EulerAnglesFromQuaternion(this.previousQuaternion * new Quaternion(this.rotationAxis, angleInDegrees2)) - selected3DElement.CanonicalRotationAngles);

            this.previousQuaternion = this.initialQuaternion * new Quaternion(this.rotationAxis, angleInDegrees1);
            Vector3D vector3D = selected3DElement.CanonicalRotationAngles + unitEulerAngles;

            vector3D = new Vector3D(RoundingHelper.RoundAngle(vector3D.X), RoundingHelper.RoundAngle(vector3D.Y), RoundingHelper.RoundAngle(vector3D.Z));
            selected3DElement.CanonicalRotationAngles = vector3D;
        }