Esempio n. 1
0
        /// <summary>
        /// Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public Tween Rotation(RotationUnit unit = RotationUnit.Degrees)
        {
            behavior |= GlideLerper.Behavior.Rotation;
            behavior |= (unit == RotationUnit.Degrees) ? GlideLerper.Behavior.RotationDegrees : GlideLerper.Behavior.RotationRadians;

            return(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public ITweenable Rotation(RotationUnit unit = RotationUnit.Degrees)
        {
            behavior |= LerpBehaviors.Rotation;
            behavior |= (unit == RotationUnit.Degrees) ? LerpBehaviors.RotationDegrees : LerpBehaviors.RotationRadians;

            return(this);
        }
Esempio n. 3
0
        /// <summary>
        ///     Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public Tween Rotation(RotationUnit unit = RotationUnit.Degrees)
        {
            behavior |= Lerper.Behavior.Rotation;
            behavior |= unit == RotationUnit.Degrees ? Lerper.Behavior.RotationDegrees : Lerper.Behavior.RotationRadians;

            return(this);
        }
Esempio n. 4
0
        public double CalculateAngle(Point p1, Point rotationCenter, RotationUnit unit)
        {
            double result = 0;

            result = CalculateArcTangens(p1, rotationCenter);
            result = ConvertFromRadiansTo(result, unit);
            return(result);
        }
Esempio n. 5
0
        private double ConvertFromRadiansTo(double radians, RotationUnit unit)
        {
            double result = 0;

            if (unit == RotationUnit.Radians)
            {
                result = radians;
            }
            else if (unit == RotationUnit.Degrees)
            {
                result = radians * 180f / Math.PI;
            }

            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public Tween Rotation(RotationUnit unit = RotationUnit.Degrees)
        {
            behavior    |= Behavior.Rotation;
            rotationUnit = unit;

            int i = vars.Count;

            while (i-- > 0)
            {
                float angle = start[i];

                if (rotationUnit == RotationUnit.Radians)
                {
                    angle *= DEG;
                }

                if (angle < 0)
                {
                    angle = 360 + angle;
                }

                float r = angle + range[i];

                float d = r - angle;
                float a = (float)Math.Abs(d);

                if (a > 181)
                {
                    r = (360 - a) * (d > 0 ? -1 : 1);
                }
                else if (a < 179)
                {
                    r = d;
                }
                else
                {
                    r = 180;
                }

                range[i] = r;
            }

            return(this);
        }
Esempio n. 7
0
        /// <summary>
        /// Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public Tween Rotation(RotationUnit unit = RotationUnit.Degrees) {
            behavior |= GlideLerper.Behavior.Rotation;
            behavior |= (unit == RotationUnit.Degrees) ? GlideLerper.Behavior.RotationDegrees : GlideLerper.Behavior.RotationRadians;

            return this;
        }
Esempio n. 8
0
 /// <summary>
 /// Creates a new angular feed constant unit based on angle per rotation.
 /// </summary>
 /// <param name="angleUnit">The angle feed per rotation</param>
 /// <param name="rotations">The rotations the angle feed is based on.</param>
 public AngularFeedConstantUnit(PlaneAngleUnit angleUnit, RotationUnit rotations) :
     base(new UnitCompositeCollection() { new MultipliedByUnit(angleUnit, 1), new DividedByUnit(rotations, 1) })
 {
 }
Esempio n. 9
0
 public void Load(IPersistStream stream)
 {
     _rotationFieldName = (string)stream.Load("RotationFieldname", "");
     _rotType           = (RotationType)stream.Load("RotationType", RotationType.aritmetic);
     _rotUnit           = (RotationUnit)stream.Load("RotationUnit", RotationUnit.deg);
 }
Esempio n. 10
0
        private void OnValidate()
        {
            if (!activeRotationUnitInitialised)
            {
                activeRotationUnitInitialised = true;
                activeRotationUnit = rotationUnit;
            }

            if (activeRotationUnit != rotationUnit)
            {
                if (rotationUnit == RotationUnit.Degrees)
                {
                    if (activeRotationUnit == RotationUnit.MilliTau)
                        rotationSpeed = (float)(rotationSpeed * Mathd.mτToDeg);
                }
                if (rotationUnit == RotationUnit.MilliTau)
                {
                    if (activeRotationUnit == RotationUnit.Degrees)
                        rotationSpeed = (float)(rotationSpeed * Mathd.DegTomτ);
                }
                activeRotationUnit = rotationUnit;
            }
        }
Esempio n. 11
0
 public void SetRotationSpeed(float newRotationSpeed, RotationUnit newRotationUnit)
 {
     rotationSpeed = newRotationSpeed;
     rotationUnit = newRotationUnit;
 }
Esempio n. 12
0
        /// <summary>
        /// Whether this tween handles rotation.
        /// </summary>
        /// <returns>A reference to this.</returns>
        public Tween Rotation(RotationUnit unit = RotationUnit.Degrees)
        {
            behavior |= Behavior.Rotation;
            rotationUnit = unit;

            int i = vars.Count;
            while (i --> 0)
            {
                float angle = start[i];

                if (rotationUnit == RotationUnit.Radians)
                    angle *= DEG;

                if (angle < 0)
                    angle = 360 + angle;

                float r = angle + range[i];

                float d = r - angle;
                float a = (float) Math.Abs(d);

                if (a > 181)
                {
                    r = (360 - a) * (d > 0 ? -1 : 1);
                }
                else if (a < 179)
                {
                    r = d;
                }
                else
                {
                    r = 180;
                }

                range[i] = r;
            }

            return this;
        }
Esempio n. 13
0
 /// <summary>
 /// Creates a new distance feed constant unit based distance per rotation
 /// </summary>
 /// <param name="distanceUnit">The distance feed per rotation</param>
 /// <param name="rotations">The rotations the distance feed is based on.</param>
 public DistanceFeedConstantUnit(LengthUnit distanceUnit, RotationUnit rotations) :
     base(new UnitCompositeCollection() { new MultipliedByUnit(distanceUnit, 1), new DividedByUnit(rotations, 1) })
 {
 }
Esempio n. 14
0
 /// <summary>
 /// Creates a new angular feed constant unit based on units per rotation.
 /// </summary>
 /// <param name="genericUnit">The angle feed per rotation</param>
 /// <param name="rotations">The rotations the angle feed is based on.</param>
 public GenericFeedConstantUnit(GenericUnit genericUnit, RotationUnit rotations) :
     base(new UnitCompositeCollection() { new MultipliedByUnit(genericUnit, 1), new DividedByUnit(rotations, 1) })
 {
 }