/** * Prepare transformation matrix from local rectangle roof coordinates to * global building coordinates. * * @param startPoint * rectangle roof starting point * @param height * roof minimal height * @param alpha * roof angle * @return */ public static SimpleMatrix prepareTransformToGlobalMatrix3d(Point2d startPoint, double height, double alpha) { SimpleMatrix transf = TransformationMatrix3d.tranA(startPoint.x, height, -startPoint.y); SimpleMatrix rot = TransformationMatrix3d.rotYA(alpha); // XXX test me return transf.mult(rot); }
private static int[][] buildSoftNormalsIndexs(MeshFactory meshFactory, int sectionCount, Point2d[] crossSection, int crossCount) { Vector2d[] crossSectionSoftNormals = calsSoftNormals(crossSection); int[][] softNormalsIntex = new int[sectionCount][]; for (int i = 0; i < sectionCount; i++) { double a = Math.toRadians(360) / sectionCount * i; SimpleMatrix rotY = TransformationMatrix3d.rotYA(a); softNormalsIntex[i] = new int[crossCount]; for (int j = 0; j < crossSection.length; j++) { // point Vector2d n2d = crossSectionSoftNormals[j]; Vector3d n = new Vector3d(n2d.x, n2d.y, 0); Vector3d transform = TransformationMatrix3d.transform(n, rotY); int in = meshFactory.addNormal(transform); softNormalsIntex[i][j] = in; } } return softNormalsIntex; }
private static Point3d[][] buildMesh(Point2d center, Point2d[] crossSection, int sectionCount) { int crossCount = crossSection.length; Point3d[][] mesh = new Point3d[sectionCount][]; for (int i = 0; i < sectionCount; i++) { double a = Math.toRadians(360) / sectionCount * i; SimpleMatrix tranA = TransformationMatrix3d.tranA(center.x, 0, -center.y); SimpleMatrix rotY = TransformationMatrix3d.rotYA(a); SimpleMatrix trans = tranA.mult(rotY); Point3d[] crossMesh = new Point3d[crossCount]; for (int j = 0; j < crossSection.length; j++) { // point Point2d cross = crossSection[j]; Point3d p = new Point3d(cross.x, cross.y, 0); crossMesh[j] = TransformationMatrix3d.transform(p, trans); } mesh[i] = crossMesh; } return mesh; }
protected void saveRenderConfiguration(LightConfiguration lightLocation) { lightLocation.getAmbientColor().getColorComponents(ambientLightColor); lightLocation.getDiffuseColor().getColorComponents(diffuseLightColor); Vector3d vector = new Vector3d(0, 0, -1); SimpleMatrix directionMatric = TransformationMatrix3d.rotYA(Math.toRadians(-lightLocation.getDirection())); SimpleMatrix angleMatric = TransformationMatrix3d.rotXA(Math.toRadians(lightLocation.getAngle())); SimpleMatrix matrix = directionMatric.mult(angleMatric); Vector3d position = TransformationMatrix3d.transform(vector, matrix); lightPosition[0] = (float) position.x; lightPosition[1] = (float) position.y; lightPosition[2] = (float) position.z; lightPosition[3] = 0f; }
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; }