Пример #1
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));
        }