Beispiel #1
0
 public static void NormalizeInPlace(this VectorDouble[] vecs)
 {
     for (int i = 0; i < vecs.Length; i++)
     {
         vecs[i] = VectorDouble.Normalize(vecs[i]);
     }
 }
        public static bool IsFlipped(this Matrix3x2Double matrix)
        {
            if (matrix.IsIdentity)
            {
                return(false);
            }
            VectorDouble vec  = new VectorDouble(1.0, 0.0);
            VectorDouble num2 = matrix.Transform(vec);
            double       num4 = Math.Atan2(num2.Y, num2.X) * 57.295779513082323;
            VectorDouble num5 = new VectorDouble(0.0, 1.0);
            VectorDouble num6 = matrix.Transform(num5);
            double       num8 = (Math.Atan2(num6.Y, num6.X) * 57.295779513082323) - 90.0;

            while (num4 < 0.0)
            {
                num4 += 360.0;
            }
            while (num8 < 0.0)
            {
                num8 += 360.0;
            }
            double num9 = Math.Abs((double)(num4 - num8));

            return((num9 > 1.0) && (num9 < 359.0));
        }
Beispiel #3
0
 public static VectorDouble NormalizeOrZeroCopy(this VectorDouble vec)
 {
     if (vec.Length == 0.0)
     {
         return(new VectorDouble(0.0, 0.0));
     }
     return(VectorDouble.Normalize(vec));
 }
Beispiel #4
0
        private static VectorDouble RotateCopy(this VectorDouble vec, double angle)
        {
            double num    = (angle * 3.1415926535897931) / 180.0;
            double length = vec.Length;
            double d      = num + Math.Atan2(vec.Y, vec.X);
            double x      = Math.Cos(d);

            return(new VectorDouble(x, Math.Sin(d)));
        }
        public static double GetRotationRadians(this Matrix3x2Double matrix)
        {
            if (matrix.IsIdentity)
            {
                return(0.0);
            }
            VectorDouble vec  = new VectorDouble(1.0, 0.0);
            VectorDouble num2 = matrix.Transform(vec);

            return(Math.Atan2(num2.Y, num2.X));
        }
Beispiel #6
0
            public Radial(PointDouble startPoint, PointDouble endPoint) : base(startPoint, endPoint)
            {
                VectorDouble num2   = (VectorDouble)(endPoint - startPoint);
                double       length = num2.Length;

                if (length == 0.0)
                {
                    this.invDistanceScale = 0.0;
                }
                else
                {
                    this.invDistanceScale = 1.0 / length;
                }
            }
Beispiel #7
0
            protected LinearBase(PointDouble startPoint, PointDouble endPoint) : base(startPoint, endPoint)
            {
                VectorDouble num    = (VectorDouble)(endPoint - startPoint);
                double       length = num.Length;

                if (base.endPointX == base.startPointX)
                {
                    this.dtdx = 0.0;
                }
                else
                {
                    this.dtdx = num.X / (length * length);
                }
                if (base.endPointY == base.startPointY)
                {
                    this.dtdy = 0.0;
                }
                else
                {
                    this.dtdy = num.Y / (length * length);
                }
            }
Beispiel #8
0
 public static bool IsCloseToZero(this VectorDouble vec) =>
 (DoubleUtil.IsCloseToZero(vec.X) && DoubleUtil.IsCloseToZero(vec.Y));
Beispiel #9
0
 public static RectDouble Offset(RectDouble rect, VectorDouble offset) =>
 Offset(rect, offset.x, offset.y);
Beispiel #10
0
 public PointAndTangentDouble(PointDouble point, VectorDouble tangent)
 {
     this.point   = point;
     this.tangent = tangent;
 }
Beispiel #11
0
 public static PointDouble Offset(PointDouble pt, VectorDouble offset) =>
 new PointDouble(pt.x + offset.x, pt.y + offset.y);