Esempio n. 1
0
        /// <summary>
        /// Minimal degree between vectors
        /// </summary>
        public static float Angle(this PointF c1, PointF c2)
        {
            var a = c1.Angle() - c2.Angle();

            a += (float)((a > Math.PI) ? -2 * Math.PI : (a < -Math.PI) ? 2 * Math.PI : 0);

            return(a);
        }
Esempio n. 2
0
        /// <summary>
        /// Минимальный угол между векторами, в рад
        /// </summary>
        /// <param name="vector1"></param>
        /// <param name="vector2"></param>
        /// <returns>число - угол</returns>
        public static float Angle(this PointF vector1, PointF vector2)
        {
            var a = vector1.Angle() - vector2.Angle();

            a += (a > PI) ? -2 * PI : (a < -PI) ? 2 * PI : 0;

            return(a);
        }
Esempio n. 3
0
        public static PointF Rotate(this PointF inputPoint, float angle)
        {
            if (Math.Abs(angle) < 0.0001f)
            {
                return(inputPoint);
            }
            float oldAngle = inputPoint.Angle();
            float h        = inputPoint.Magnitude();
            float newAngle = oldAngle + angle;
            float newx     = h * (float)Math.Cos((double)newAngle);
            float newy     = h * (float)Math.Sin((double)newAngle);

            return(new PointF(newx, newy));
        }
Esempio n. 4
0
        public static PointF SetLength(this PointF inputPoint, float magnitude)
        {
            float angle = inputPoint.Angle();

            return(new PointF(magnitude * (float)Math.Cos(angle), magnitude * (float)Math.Sin(angle)));
        }