Exemple #1
0
        /// <summary>
        /// Initialises an angle as the signed difference between two directions in the 2D plane.
        /// The returned value is the smallest negative angle from one direction to the other.
        /// </summary>
        public static Angle BetweenNegative(Direction2 from, Direction2 to)
        {
            var a = Angle.Between(from, to);

            if (a.radians > 0)
            {
                a -= Mathf.TwoPi.Radians();
            }
            return(a);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new polar position.
        /// </summary>
        /// <param name="r">The distance of the point to the origin.</param>
        /// <param name="angle">The direction of the vector originating in the origin pointing towards the point.</param>
        public PolarPosition(float r, Direction2 angle)
        {
            if (r < 0)
            {
                throw new ArgumentException("The radius has to be non-negative.");
            }

            R     = r;
            Angle = angle;
        }
Exemple #3
0
 /// <summary>
 /// Initialises an angle as the signed difference between two directions in the 2D plane.
 /// The returned value is the smallest possible angle from one direction to the other.
 /// </summary>
 public static Angle Between(Direction2 from, Direction2 to)
 {
     return(to - from);
 }
Exemple #4
0
 /// <summary>
 /// Converts an Euclidean position into polar coordinates.
 /// </summary>
 /// <param name="position">The Euclidean representation of the point.</param>
 /// <returns>The polar representation of the specified point.</returns>
 public static PolarPosition FromVector2(Vector2 position)
 {
     return(new PolarPosition(position.Length, Direction2.Of(position)));
 }