public RectangleRoofHooksSpace(Point2d p1, Vector2d v1, double b, Plane3d pPlane) { super(); // this.p1 = p1; // this.v1 = v1; this.b = b; double angle = Math.atan2(v1.y, v1.x); // Math.toDegrees(angle); SimpleMatrix tr2d = TransformationMatrix2d.rotZA(-angle).mult(TransformationMatrix2d.tranA(-p1.x, -p1.y)); SimpleMatrix tr3d = TransformationMatrix3d.rotYA(-angle).mult(TransformationMatrix3d.tranA(-p1.x, 0, p1.y)); this.p1 = TransformationMatrix2d.transform(p1, tr2d); this.v1 = TransformationMatrix2d.transform(v1, tr2d); Point3d planePoint = TransformationMatrix3d.transform(pPlane.getPoint(), tr3d); Vector3d planeNormal = TransformationMatrix3d.transform(pPlane.getNormal(), tr3d); this.plane = new Plane3d(planePoint, planeNormal); SimpleMatrix trBack = TransformationMatrix3d.rotYA(angle).mult(TransformationMatrix3d.tranA(-p1.x, 0, p1.y)); this.transformationMatrix = trBack; }
public PolygonRoofHooksSpace( Point2d p1, Vector2d v1, List<List<Point2d>> pPolygon, Plane3d pPlane) { super(); // this.p1 = p1; // this.v1 = v1; this.b = this.b; double angle = Math.atan2(v1.y, v1.x); // Math.toDegrees(angle); SimpleMatrix tr2d = TransformationMatrix2d.rotZA(-angle).mult(TransformationMatrix2d.tranA(-p1.x, -p1.y)); SimpleMatrix tr3d = TransformationMatrix3d.rotYA(-angle).mult(TransformationMatrix3d.tranA(-p1.x, 0, p1.y)); this.p1 = TransformationMatrix2d.transform(p1, tr2d); this.v1 = TransformationMatrix2d.transform(v1, tr2d); List<List<Point2d>> transformPolygons = new ArrayList<List<Point2d>>(); for (List<Point2d> polygon : pPolygon) { List<Point2d> transformPolygon = new ArrayList<Point2d>(); for (Point2d point : polygon) { transformPolygon.add(TransformationMatrix2d.transform(point, tr2d)); } transformPolygons.add(transformPolygon); } this.polygon = transformPolygons; Point3d planePoint = TransformationMatrix3d.transform(pPlane.getPoint(), tr3d); Vector3d planeNormal = TransformationMatrix3d.transform(pPlane.getNormal(), tr3d); this.plane = new Plane3d(planePoint, planeNormal); SimpleMatrix trBack = TransformationMatrix3d.tranA(p1.x, 0, -p1.y).mult(TransformationMatrix3d.rotYA(angle)); // SimpleMatrix trBack = // TransformationMatrix3d.rotYA(angle).mult(TransformationMatrix3d.tranA(-p1.x, 0, p1.y)); // TransformationMatrix3d.transform(planePoint, trBack) this.transformationMatrix = trBack; }