Esempio n. 1
0
        public MATRIX CrossMatrix(MATRIX Matrix2)
        {
            double[,] M2      = Matrix2.Matrix;
            double[,] resData = new double[this.row, M2.GetLength(1)];
            for (int i = 0; i < this.row; i++)
            {
                for (int j = 0; j < M2.GetLength(1); j++)
                {
                    resData[i, j] = VectorDot(getVector(this.Matrix, i, "ROW"), getVector(M2, j, "COL"));
                }
            }

            return(new MATRIX(resData));
        }
Esempio n. 2
0
        public XYZ GetCrossPoint(LINE line2)
        {
            if (this.IsSameDirection(line2.GetDirection(), true))
            {
                LINE tmpLine = new LINE(this.GetEndPoint(), line2.GetStartPoint());
                if (this.IsSameDirection(tmpLine.Direction, true))
                {
                    if (this.IsSameDirection(line2.Direction, true))
                    {
                        return((this.GetEndPoint() + line2.GetStartPoint()) / 2);
                    }
                    else
                    {
                        return((this.GetStartPoint() + line2.GetStartPoint()) / 2);
                    }
                }
                else
                {
                    return(this.GetEndPoint());
                }
            }

            MATRIX m1 = new MATRIX(new double[, ] {
                { this.Direction.X, -line2.Direction.X },
                { this.Direction.Y, -line2.Direction.Y }
            });
            MATRIX m2 = new MATRIX(new double[, ] {
                { line2.OriPoint.X - this.OriPoint.X }, { line2.OriPoint.Y - this.OriPoint.Y }
            });

            MATRIX m3  = m1.InverseMatrix();
            MATRIX res = m3.CrossMatrix(m2);

            double[,] tt = res.Matrix;
            double newX = this.OriPoint.X + this.Direction.X * tt[0, 0];
            double newY = this.OriPoint.Y + this.Direction.Y * tt[0, 0];

            return(new XYZ(newX, newY, this.OriPoint.Z));
        }