Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 774 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to project a point onto a plane in 3D?

#1
I have a 3D point (point_x,point_y,point_z) and I want to project it onto a 2D plane in 3D space which (the plane) is defined by a point coordinates (orig_x,orig_y,orig_z) and a unary perpendicular vector (normal_dx,normal_dy,normal_dz).

How should I handle this?![enter image description here][1]


[1]:
Reply

#2
Let V = (orig_x,orig_y,orig_z) - (point_x,point_y,point_z)

N = (normal_dx,normal_dy,normal_dz)

Let d = V.dotproduct(N);

Projected point P = V + d.N
Reply

#3
It's not sufficient to provide only the plane origin and the normal vector. This does define the 3d plane, however this does not define the coordinate system on the plane.

Think that you may rotate your plane around the normal vector with regard to its origin (i.e. put the normal vector at the origin and "rotate").

You may however find the distance of the projected point to the origin (which is obviously invariant to rotation).

Subtract the origin from the 3d point. Then do a cross product with the normal direction. If your normal vector is normalized - the resulting vector's length equals to the needed value.

**EDIT**

A complete answer would need an extra parameter. Say, you supply also the vector that denotes the x-axis on your plane.
So we have vectors **n** and **x**. Assume they're normalized.

The origin is denoted by **O**, your 3D point is **p**.

Then your point is projected by the following:

x = (**p** - **O**) dot **x**

y = (**p** - **O**) dot (**n** cross **x**)
Reply

#4
I think you should slightly change the way you describe the plane. Indeed, the best way to describe the plane is via a vector **n** and a scalar *c*

(**x**, **n**) = *c*

The (absolute value of the) constant c is the *distance* of the plane from the origin, and is equal to (**P**, **n**), where **P** is any point on the plane.

So, let **P** be your *orig* point and **A**' be the projection of a new point **A** onto the plane. What you need to do is find *a* such that **A**' = **A** - a***n** satisfies the equation of the plane, that is

(**A** - a***n**, **n**) = (**P**, **n**)

Solving for a, you find that

a = (**A**, **n**) - (**P**, **n**) = (**A**, **n**) - *c*

which gives

**A**' = **A** - [(**A**, **n**) - c]**n**

Using your names, this reads

c = orig_x*normal_dx + orig_y*normal_dy+orig_z*normal_dz;
a = point_x*normal_dx + point_y*normal_dy + point_z*normal_dz - c;
planar_x = point_x - a*normal_dx;
planar_y = point_y - a*normal_dy;
planar_z = point_z - a*normal_dz;


Note: your code would save one scalar product if instead of the *orig* point **P** you store c=(**P**, **n**), which means basically 25% less flops for each projection (in case this routine is used many times in your code).
Reply

#5
This is really easy, all you have to do is find the perpendicular (abbr here `|_`) distance from the point `P` to the plane, then _translate_ `P` __back__ by the perpendicular distance _in the direction of the plane normal_. The result is the translated `P` sits in the plane.

Taking an easy example (that we can verify by inspection) :

Set n=(0,1,0), and P=(10,20,-5).

![enter image description here][1]

The projected point should be (10,10,-5). You can see by inspection that Pproj is 10 units perpendicular from the plane, and if it were in the plane, it would have y=10.

So how do we find this analytically?

The plane equation is Ax+By+Cz+d=0. What this equation means is __"in order for a point (x,y,z) to be in the plane, it must satisfy Ax+By+Cz+d=0"__.

What is the Ax+By+Cz+d=0 equation for the plane drawn above?

The plane has normal n=(0,1,0). The d is found simply by using a test point _already in the plane_:

(0)x + (1)y + (0)z + d = 0

The point (0,10,0) is in the plane. Plugging in above, we find, d=-10. The plane equation is then 0x + 1y + 0z - 10 = 0 (if you simplify, you get y=10).

A nice interpretation of `d` is it speaks of the __perpendicular distance you would need to translate the plane along its normal to have the plane pass through the origin__.

Anyway, once we have `d`, we can find the |_ distance of _any_ point to the plane by the following equation:

![enter image description here][2]

There are 3 possible classes of results for |_ distance to plane:

- 0: ON PLANE EXACTLY (almost never happens with floating point inaccuracy issues)
- +1: >0: IN FRONT of plane (on normal side)
- -1: <0: BEHIND plane (ON OPPOSITE SIDE OF NORMAL)

Anyway,

![enter image description here][3]

Which you can verify as correct by inspection in the diagram above

[1]:

[2]:

[3]:
Reply

#6
Let **r** be the point to project and **p** be the result of the projection. Let **c** be any point on the plane and let **n** be a normal to the plane (not necessarily normalised). Write **p** = **r** + m **d** for some scalar m which will be seen to be indeterminate if their is no solution.
Since (**p** - **c**).**n** = 0 because all points on the plane satisfy this restriction one has (**r** - **c**).**n** + m(**d** . **n**) = 0 and so m = [(**c** - **r**).**n**]/[**d**.**n**] where the dot product (.) is used. But if **d**.**n** = 0 there is no solution. For example if **d** and **n** are perpendicular to one another no solution is available.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through