Exemple #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);
        }
Exemple #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);
        }
        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);
        }
Exemple #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));
        }
Exemple #5
0
 internal double Cross(DmtxVector2 v2)
 {
     return(this._x * v2._y - this._y * v2._x);
 }
Exemple #6
0
 internal double Dot(DmtxVector2 v2)
 {
     return(Math.Sqrt(_x * v2._x + _y * v2._y));
 }
 internal double Dot(DmtxVector2 v2)
 {
     return(Math.Sqrt(this.X * v2.X + this.Y * v2.Y));
 }
 internal double Cross(DmtxVector2 v2)
 {
     return(this.X * v2.Y - this.Y * v2.X);
 }