Exemplo n.º 1
0
        public static DmtxVector2 operator -(DmtxVector2 v1, DmtxVector2 v2)
        {
            DmtxVector2 result = new DmtxVector2(v1.X, v1.Y);

            result.X -= v2.X;
            result.Y -= v2.Y;
            return(result);
        }
Exemplo n.º 2
0
        internal bool PointAlongRay2(DmtxRay2 ray, double t)
        {
            if (Math.Abs(1.0 - ray.V.Mag()) > DmtxConstants.DmtxAlmostZero)
            {
                throw new ArgumentException("PointAlongRay: The ray's V vector must be a unit vector");
            }
            DmtxVector2 tmp = new DmtxVector2(ray.V.X * t, ray.V.Y * t);

            this.X = ray.P.X + tmp.X;
            this.Y = ray.P.Y + tmp.Y;
            return(true);
        }
Exemplo n.º 3
0
        public static DmtxVector2 operator *(DmtxVector2 vector, DmtxMatrix3 matrix)
        {
            double w = Math.Abs(vector.X * matrix[0, 2] + vector.Y * matrix[1, 2] + matrix[2, 2]);

            if (w <= DmtxConstants.DmtxAlmostZero)
            {
                throw new ArgumentException("Multiplication of vector and matrix resulted in invalid result");
            }
            DmtxVector2 result = new DmtxVector2((vector.X * matrix[0, 0] + vector.Y * matrix[1, 0] + matrix[2, 0]) / w,
                                                 (vector.X * matrix[0, 1] + vector.Y * matrix[1, 1] + matrix[2, 1]) / w);

            return(result);
        }
Exemplo n.º 4
0
        internal static double RightAngleTrueness(DmtxVector2 c0, DmtxVector2 c1, DmtxVector2 c2, double angle)
        {
            DmtxVector2 vA = (c0 - c1);
            DmtxVector2 vB = (c2 - c1);

            vA.Norm();
            vB.Norm();

            DmtxMatrix3 m = DmtxMatrix3.Rotate(angle);

            vB *= m;

            return(vA.Dot(vB));
        }
Exemplo n.º 5
0
 internal double Dot(DmtxVector2 v2)
 {
     return(Math.Sqrt(this.X * v2.X + this.Y * v2.Y));
 }
Exemplo n.º 6
0
 internal double Cross(DmtxVector2 v2)
 {
     return(this.X * v2.Y - this.Y * v2.X);
 }