New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting geocoordinates of all vertices #747

Closed
Dakki97 opened this Issue Apr 18, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@Dakki97

Dakki97 commented Apr 18, 2018

Hi, so I am currently working on aquiring the geo coordinates from all vertices of parts such as walls etc. and was not able to find a method to aquire them. What i tried so far : getting the float matrices of
getData().getVertices and getGeometry().transformation and transforming the vertices according to the corresponding matrix did not work. Next i tried working recursively through the relative placements but I don't really know how i should approach this. My approaches were taken from past issues.
Is there a simple way of achieving this or a simple workaround or do I have to learn linear algebra now ?
Thanks in advance!

@rubendel

This comment has been minimized.

Member

rubendel commented Apr 18, 2018

Any vertex transformed by the transformation matrix of the object will result in the final location of the given vertex within the model, nothing more is required, all the relative stuff is already accumulated in the matrix. You said it does not work, can you elaborate?

@Dakki97

This comment has been minimized.

Dakki97 commented Apr 18, 2018

Thank you for the quick answer,
Well it is not not working but the coordinates are not correct as it appears since i know the correct coordinates. Did not state my issue correctly. Basically I am looking for the correct way to output geocoordinates.
The code I used to transform my vertices is as follows:

            List<IfcWall> products = model.getAll(IfcWall.class);
            float[] coordinatematrix = null;
            for (IfcWall product : products) {
                exporter += product.getGlobalId() + "\n";
                if (product.getGeometry() != null) {
                    //  Transformation Matrix
                    float[] transformationmatrix = GeometryUtils.toFloatArray(product.getGeometry().getTransformation());
                    //  Coordinate matrix
                    coordinatematrix = GeometryUtils.toFloatArray(product.getGeometry().getData().getVertices());

                    //  Apply Transformation
                    Transform3D transform = new Transform3D(transformationmatrix);
                    for (int i = 2; i < coordinatematrix.length; i = i + 3) {
                        Point3f p = new Point3f(coordinatematrix[i - 2], coordinatematrix[i - 1], coordinatematrix[i]);
                        transform.transform(p);
                        exporter += p.x + ", " + p.y + ", " + p.z + "\n";
                    }
                }
            }

My transformation matrix for one object looks like this and for every other it is similar:
1zztGAbpPAFe7iHU1R3Vx7
0.0
0.0
0.0
1.875
0.0
0.0
0.0
0.0
0.0
-1.875
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1.875
0.0
0.0
0.0
2.9296875
0.0
3.0078125
0.0
-2.625
0.0
1.875
My coordinatematrix for one element looks something like this:

7.0416665
0.22916667
0.0
7.0416665
0.22916667
50.0
0.0
0.22916667
0.0
0.0
0.22916667
50.0
0.0
0.22916667
0.0
0.0
0.22916667
50.0
0.0
-0.22916667
0.0
0.0
-0.22916667
50.0
0.0
-0.22916667
0.0
0.0
-0.22916667
50.0
7.0416665
-0.22916667
0.0
7.0416665
-0.22916667
50.0
7.0416665
-0.22916667
0.0
7.0416665
-0.22916667
50.0
7.0416665
0.22916667
0.0
7.0416665
0.22916667
50.0
7.0416665
0.22916667
0.0
0.0
0.22916667
0.0
0.0
-0.22916667
0.0
7.0416665
-0.22916667
0.0
7.0416665
0.22916667
50.0
0.0
0.22916667
50.0
0.0
-0.22916667
50.0
7.0416665
-0.22916667
50.0
This is the result for the first object:
1zztGAbpPAFe7iHU1R3Vx7
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, -0.4296875
1.875, 0.0, 0.4296875
1.875, 0.0, 0.4296875

@Dakki97

This comment has been minimized.

Dakki97 commented Apr 18, 2018

My bad, wrote the issue as if it was a bug but it is more of a "how to" question

What i further tried was changing the matrices to double arrays and changing the orientation of the matrix which resulted in a more logical output but some coordinates are absurdly high while some others look legitimate
This is the current code:

            project = client.getServiceInterface().getProjectByPoid(project.getOid());
            ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), true, false, true);
            List<IfcWall> products = model.getAll(IfcWall.class);
            for (IfcWall product : products) {
                exporter += product.getGlobalId() + "\n";
                if (product.getGeometry() != null) {
                    //  Transformation Matrix
                    double[] transformationmatrix = GeometryUtils.toDoubleArray(product.getGeometry().getTransformation());
                    //  Coordinate matrix
                    double[] coordinatematrix = GeometryUtils.toDoubleArray(product.getGeometry().getData().getVertices());
                    //  Apply Transformation
                    transformationmatrix=Matrix.changeOrientation(transformationmatrix);
                    Transform3D transform = new Transform3D(transformationmatrix);
                    for (int i = 2; i < coordinatematrix.length; i = i + 3) {
                        Point3d p = new Point3d(coordinatematrix[i - 2], coordinatematrix[i - 1], coordinatematrix[i]);
                        transform.transform(p);
                        exporter += p.x + ", " + p.y + ", " + p.z + "\n";
                    }
                }
            }
            ExportData("Edgevertices.txt");

The output now is
-35471.15625, 33.000000049670554, 2.0615846215333334E11
27.5, 33.00000004967055, 2.0615846215333334E11
27.5, 33.00000004967055, 2.0615846215333334E11
27.5, 32.99999995032945, 2.0615852768933334E11
27.5, 32.99999995032945, 2.0615852768933334E11
-35471.15625, 32.999999950329446, 2.0615852768933334E11
-35471.15625, 32.999999950329446, 2.0615852768933334E11
-35471.15625, 33.000000049670554, 2.0615846215333334E11
27.5, 33.000000049670554, -12.0
-35471.15625, 32.99999995032945, -12.0
27.5, 33.000000049670554, 2.0615846215333334E11
-35471.1643409729, 32.99999995032945, 2.0615852768933334E11

@rubendel rubendel closed this Oct 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment