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); }
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)); }
public void Merging(VECTOR[] Data1, VECTOR[] Data2) { VECTOR p1 = Data1[1]; VECTOR p2 = Data1[3]; VECTOR p3 = Data2[0]; VECTOR p4 = Data2[2]; VECTOR d1 = (p4 - p3).UnitForm(); VECTOR d2 = (p2 - p1).UnitForm(); MATRIX RotaMatri_1 = new MATRIX(new double[, ] { { d2.X, d2.Y }, { -d2.Y, d2.X } }); MATRIX RotaMatri_2 = new MATRIX(new double[, ] { { d1.X, d1.Y }, { -d2.Y, d2.X } }); //// 以基準點平移 Data1 = ShiftFromTargetPoint(Data1, Data1[1]); Data2 = ShiftFromTargetPoint(Data2, Data2[0]); ShowData(Data1); ShowData(Data2); }
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)); }