Let A be a point for which I have the 3D coordinates x, y, z and I want to transform them into 2D coordinates: x, y. The projection shall be orthogonal on a plane defined by a given normal. The trivial case, where the normal is actually one of the axes, it's easy to solve, simply eliminating a coordinate, but how about the other cases, which are more likely to happen?
相关问题
- Is GLFW designed to use without LWJGL (in java)?
- d3.js moving average with previous and next data v
- How to get a fixed number of evenly spaced points
- Check if a number is a perfect power of another nu
- How to determine +/- sign when calculating diagona
相关文章
- ceil conterpart for Math.floorDiv in Java?
- why 48 bit seed in util Random class?
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- Keep constant number of visible circles in 3D anim
- Need help generating discrete random numbers from
- How do you create a formula that has diminishing r
If you have your target point P with coordinates
r_P = (x,y,z)
and a plane with normaln=(nx,ny,nz)
you need to define an origin on the plane, as well as two orthogonal directions forx
andy
. For example if your origin is atr_O = (ox, oy, oz)
and your two coordinate axis in the plane are defined bye_1 = (ex_1,ey_1,ez_1)
,e_2 = (ex_2,ey_2,ez_2)
then orthogonality has thatDot(n,e_1)=0
,Dot(n,e_2)=0
,Dot(e_1,e_2)=0
(vector dot product). Note that all the direction vectors should be normalized (magnitude should be one).Your target point P must obey the equation:
where
t_1
andt_2
are your 2D coordinates alonge_1
ande_2
ands
the normal separation (distance) between the plane and the point.There scalars are found by projections:
Example with a plane origin
r_O = (-1,3,1)
and normal:You have to pick orthogonal directions for the 2D coordinates, for example:
such that
Dot(n,e_1) = 0
andDot(n,e_2) = 0
andDot(e_1, e_2) = 0
.The 2D coordinates of a point P
r_P=(1,7,-3)
are:and the out of plane separation:
Find the projection of
A
onto the normal direction. Then subtract that projection fromA
. What is left is the projection ofA
onto the orthogonal plane.The projection of A onto the unit normal direction
n
is given by:If
A = (x, y, z)
and the unit normal is given byn = (nx, ny, nz)
, then the projection of A onton
isSo the projection of A onto the orthogonal plane is
For example, if A = (1,2,3) and n is the unit normal in direction (4,5,6), then
So the projection of A onto the orthogonal plane is
How to find 2D coordinates:
You'll need to define a 2D coordinate system on the orthogonal plane. In other words, you need to define where the
x-axis
andy-axis
are. For example, you could define thex-axis
to be the projection of (1,0,0) onto the orthogonal plane (using the computation shown above). This will work except in the degenerate case where (1,0,0) is normal to the plane.Once you have unit vectors for the
x
andy
axis directions, then you could projectA
directly ontox
andy
. The magnitude of those vectors are the 2D coordinates.For example, this is the projection of (1,0,0) onto the plane. We take this to be the x-axis direction:
Here we compute the y-axis direction: The
y-axis
direction must be perpendicular to both the normal directionn
and tox
. So we could definey
to be the cross product ofn
andx
:So here are the coordinates for
A
in the plane: