Jump to content

Move 2d polygon in 3d space onto 2d plane


Madaxe

Recommended Posts

I have a series of 3d points in space they are on an arbitrary plane but i want to move them to a plane AX+BY+CZ+D=0 A=0, B=0, C=1, D=0 so the XY Plane.

the matrices for this is identity.

From the points i assume 

0) All vectors will be unitized
1) the first point in the polygon will be moved to 0,0,0
2) the first and second point in the polygon will define the vector for the X Axis
3) the first point and the last point in the polygon will define a construction vector
4) the cross product of the X Axis Vector and the construction vector will define the Z Axis vector
5) the cross product of the X Axis Vector and the Z Axis Vector will define the Y Axis Vector
6) using the three vectors and the origin point construct a matrices
7) invert the matrices
icon_cool.gif Multiply each polygon point by the inverse matrix to transform them to the xy plane

Does not work the polygon is moved but not rotated correctly what do i need to do?

All help is appreciated

Thanks

Madaxe

Link to comment
Share on other sites

47 minutes ago, Madaxe said:

I have a series of 3d points in space they are on an arbitrary plane

Slightly off-topic to your main question, but I would like to point out that polygon with >= 4 vertices might be non-planar i.e. not laying on a single plane at all...

If 4+ vertices were made by user of 3D application, if he or she worked in perspective view, chance to get non-planar polygon is > 99.9999%..

47 minutes ago, Madaxe said:

0) All vectors will be unitized

That's correct. But that's at the end. Because otherwise cross-product won't give you normal vector..

47 minutes ago, Madaxe said:

1) the first point in the polygon will be moved to 0,0,0

The first? You need to move them all, at the same time.. Moving the first only, would disturb shape of polygon.

47 minutes ago, Madaxe said:

2) the first and second point in the polygon will define the vector for the X Axis

...so if you will look at vector from the top (or side) (i.e. ignore one axis) you will see it's making Pythagorean triangle, from it you can calculate angle, which will be useful in further calculations.

 

Edited by Sensei
Link to comment
Share on other sites

It is more than 30 years since I did any of this but from what I remember...

You need to get the surface normal of the surface. You can do this by taking the cross product of two adjacent edges (assuming, as Sensei says, that they are coplanar).

Then you ... uhm ... just ... hmmm ... I can't remember how you calculate the required transformation matrix from that surface normal and Z! And I don't have any of my books anymore. So I will follow this thread from a sense of nostalgia!

I assume you are using homogeneous coordinates?

Link to comment
Share on other sites

Quote

Move 2d polygon in 3d space onto 2d plane

This cannot (in general) be accomplished with a single operation.

It requires one or more rotations followed by a single translation.

The rotations are required to bring the plane of the polygon parallel to the required plane.

The rotated plane can then be brought into coincidence with the required plane by a single translation.

Link to comment
Share on other sites

5 minutes ago, studiot said:

This cannot (in general) be accomplished with a single operation.

It requires one or more rotations followed by a single translation.

The rotations are required to bring the plane of the polygon parallel to the required plane.

The rotated plane can then be brought into coincidence with the required plane by a single translation.

Good point. I think (it wasn't very clear) that the OPs step 1 is the translation.

But, unless we know the polygon will be rotated about that point, as you say, the translation should be done last. (Calculating the required translation is the easy bit!)

Link to comment
Share on other sites

43 minutes ago, studiot said:

This cannot (in general) be accomplished with a single operation. 

...by single operation do you meant "multiplication of vertex by matrix", right... ?

43 minutes ago, studiot said:

It requires one or more rotations followed by a single translation. 

...OP (might) wants to use 4x4 matrix.. i.e. it contains everything, i.e. translation offset is in the last column/row..

If OP would use 3x3 obviously it can contains just rotation(s) and eventual scaling (not used by OP).

 

Edited by Sensei
Link to comment
Share on other sites

12 minutes ago, Sensei said:

.by single operation do you meant "multiplication of vertex by matrix", right... ?

I was interpreting the OP  word 'move'

That is why I quoted from the title, not from the body text of the post.

Note that in 3D space (as required) the ( 3) coordinates cannot fill out a 4 x 4 matrix.

Edited by studiot
Link to comment
Share on other sites

1 hour ago, Strange said:

But, unless we know the polygon will be rotated about that point, as you say, the translation should be done last.

Translation is done the first because of convenience, to limit number of math operations, i.e. it's done anyway to calculate angle(s) using arcsin or arccos functions.

If somebody bothers about math operations (and speed of execution), should not use matrix multiplications, as often you end up multiplying by 0 if some matrix fields are 0. (If you are compiling on CPU without built-in matrix multiplications)

39 minutes ago, studiot said:

Note that in 3D space (as required) the ( 3) coordinates cannot fill out a 4 x 4 matrix.

Computer programmers use them "all the time" during 3D transformations.. 4th vertex vector field is assumed to be 1.0

Vector4d vector = Vector4d( x, y, z, 1.0 );

Matrix4x4 matrix = Matrix4x4( [...16 fields...] );

vector *= matrix; // overloaded operator

https://stackoverflow.com/questions/29079685/how-does-4x4-matrix-work-in-3d-graphic

 

Edited by Sensei
Link to comment
Share on other sites

Has anybody considered the implications of

rotation first v translation first ?

There is more than one possible solution to the question as posed in the title.

 

Some of these solutions lead to unfortunate consequences if attempted in the real world as opposed to the abstract world of mathematical manipulation.

 

For instance consider a spacecraft docking with the spacestation or a supertanker docking with a jetty.

I would suggest it is better to line up (rotate) your craft before attempting the final docking manouevere (translation).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.