Ejemplo n.º 1
0
    // Converts an angle to an equivalent angle within the range with the given center.
    // The range will always be 360 degrees in size.
    public Angle MoveIntoInterval(Angle centerOfTheInterval)
    {
        IntervalFloat interval = IntervalFloat.FromCenterRadius(
            centerOfTheInterval.GetDegrees(), 180.0f);

        degrees = UtilPeriodic.MoveIntoInterval(degrees, interval);
        return(this);
    }
Ejemplo n.º 2
0
    // Makes the oscillator progress through time by a given amount
    // and then returns its amplitude at the new time.
    public float SampleAmplitude(float deltaTime)
    {
        progress += deltaTime * speed;

        /*
         * while (progress > Angle.TWO_PI)
         * {
         *  progress -= UtilCircle.TWO_PI;
         * }
         * while (progress < 0.0f)
         * {
         *  progress += UtilCircle.TWO_PI;
         * }
         */
        progress = UtilPeriodic.MoveIntoInterval(progress, Angle.INTERVAL_UNSIGNED_RADIANS);
        return(magnitude * waveform(progress));
    }
Ejemplo n.º 3
0
 // Returns the sign of the shortest rotation between the two angles.
 public static int SignShortestRotation(Angle start, Angle end)
 {
     return(UtilPeriodic.SignShortestRotation(
                start.GetDegrees(), end.GetDegrees(), INTERVAL_UNSIGNED_DEGREES));
 }
Ejemplo n.º 4
0
 // Like the approach float function, but rotates current along the shortest path
 // to the target, like an angle moving along a circle towards a different angle.
 public Angle Approach(Angle target, Angle stepSize)
 {
     degrees = UtilPeriodic.Approach(degrees, target.GetDegrees(),
                                     stepSize.GetDegrees(), INTERVAL_UNSIGNED_DEGREES);
     return(this);
 }
Ejemplo n.º 5
0
 // Returns true if the shortest path between the two given angles is a
 // positive (counterclockwise on the unit circle) rotation from the start angle.
 public static bool IsShortestRotationPositive(Angle start, Angle end)
 {
     return(UtilPeriodic.IsShortestRotationPositive(
                start.GetDegrees(), end.GetDegrees(), INTERVAL_UNSIGNED_DEGREES));
 }
Ejemplo n.º 6
0
 // Returns the larger distance between the two angles.
 public static Angle GetLargerDistance(Angle angle1, Angle angle2)
 {
     return(Angle.FromDegrees(UtilPeriodic.GetLargerDistance(
                                  angle1.GetDegrees(), angle2.GetDegrees(), INTERVAL_UNSIGNED_DEGREES)));
 }
Ejemplo n.º 7
0
 // Converts an angle to an equivalent angle within the [0, 360) range.
 public Angle MoveIntoUnsignedInterval()
 {
     degrees = UtilPeriodic.MoveIntoInterval(degrees, INTERVAL_UNSIGNED_DEGREES);
     return(this);
 }
Ejemplo n.º 8
0
 // Mirrors an angle across the x-axis of a circle.
 public Angle MirrorVertical()
 {
     degrees = UtilPeriodic.MirrorVertical(degrees, INTERVAL_UNSIGNED_DEGREES);
     return(this);
 }
Ejemplo n.º 9
0
 // Rotates the angle by 180 degrees, effectively reversing its direction.
 public Angle Reverse()
 {
     degrees = UtilPeriodic.Reverse(degrees, INTERVAL_UNSIGNED_DEGREES);
     return(this);
 }
Ejemplo n.º 10
0
 // Returns the signed degree measure of the angle.
 public float GetDegreesSigned()
 {
     return(UtilPeriodic.MoveIntoInterval(degrees, INTERVAL_SIGNED_DEGREES));
 }