Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transform 3D points to 2D

Tags:

math

matrix

3d

I have a set of points (x1, x2,..xn) that lie on the plane define by Ax+ By+Cz+d=0. I would like to find the transformation matrix to translate and rotate to XY plane. So, the new point coordinate will be x1'=(xnew, ynew,0).

A lot of answer give quaternion, dot or cross product matrix. I am not sure which one is the correct way.

Thank you

like image 516
stephie Avatar asked Jun 07 '11 11:06

stephie


People also ask

How do you convert 3D coordinates to 2D coordinates?

If you're talking about transforming world-space (x,y,z) coordinates to screen-space (u,v) coordinates, then the basic approach is: u = x / z; v = y / z; If the camera is not at the origin, transform (x,y,z) by the view matrix before the projection matrix.

How can you represent a 3D object on a 2D plane?

A 3D projection (or graphical projection) is a design technique used to display a three-dimensional (3D) object on a two-dimensional (2D) surface. These projections rely on visual perspective and aspect analysis to project a complex object for viewing capability on a simpler plane.

What determines the position of 3D object point on 2D image plane?

It requires a simple division of the point's x- and y-coordinate by the point's z-coordinate. Before projecting the point onto the canvas, we need to convert the point from world space to camera space. The resulting projected point is defined in image space, and is a 2D point (the z-coordinate can be discarded).

What is the need of projection explain ways of projection 3D objects onto 2D screen in detail?

It is the process of converting a 3D object into a 2D object. It is also defined as mapping or transformation of the object in projection plane or view plane. The view plane is displayed surface.


1 Answers

First of all, unless in your plane equation, d=0, there is no linear transformation you can apply. You need to instead perform an affine transformation.

One way to do this is to determine an angle and vector about which to rotate to make your pointset lie in a plane parallel to the XY plane (ie. the Z component of your transformed pointset to all have the same values). Then you simply drop the Z component.

For this, let V be the normalized plane normal for the plane containing your points. For convenience define from your plane equation above Ax+By+Cz+d=0:

V = (A, B, C)
V' = V / ||V|| = (A', B', C')
Z = (0, 0, 1)

where

A' = A / ||V||
B' = B / ||V||
C' = C / ||V||
||V|| = (A2+B2+C2)1/2

The angle will simply be:

θ = cos-1(ZV / ||V||)
  = cos-1(ZV')
  = cos-1(C')

The axis R about which to rotate is just the cross product of the normalized plane normal V' and Z. That is

R = V'×Z
  = (B', -A', 0)

You can now use this angle / axis pair to build the quaternion rotation needed to rotate all of the points in your dataset to a plane parallel to the XY plane. Then, a I said earlier, just drop the Z component to perform an orthogonal projection onto the XY plane.

Update: antonakos makes a good point about normalizing the R before using an API taking axis / angle pairs.

like image 175
andand Avatar answered Sep 25 '22 01:09

andand