Пример #1
0
        private VECTOR[] Rotation(VECTOR[] Data1, MATRIX RotaMatri_1)
        {
            //// 以基準點旋轉
            for (int i = 0; i < Data1.Count(); i++)
            {
                MATRIX vect = new MATRIX(new double[, ] {
                    { Data1[i].X }, { Data1[i].Y }
                });
                MATRIX res = RotaMatri_1.CrossMatrix(vect);
                Data1[i] = new VECTOR(res.Matrix[0, 0], res.Matrix[1, 0], 0);
            }

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