How to project 3D point to a cone

1.1k Views Asked by At

I have a set of points on the y-z plane there are some points and I would like to project them to a right cone which has its vertex on the z-axis and its flat base on the x-y plane.

Because of this it is easy to calculate the position of the point

  • we take y and z coordinates as is
  • we update the x coordinate to be the distance to the edge of the cone at the given height at z

How to do that for the general case (i.e. that we do not have the cone and plane placed in the positions to make the calculation easy), other than translations and rotations?

1

There are 1 best solutions below

0
On

In the general case, it seems you want to project the point along the plane normal and mark where it intersects the cone. I would solve this problem in the following steps.

  1. Create a transformation matrix to transform your coordinate system such that the apex of the cone is at the origin and the cone opens upward. This gives you a simple cone equation to work with: $\frac{x^2+y^2}{k^2}=z^2$
  2. Given a plane (defined by its normal and a point) and a set of points in the plane, transform all the points and the plane normal using the transformation matrix in step 1.
  3. For each point, find the intersections with the cone, if they exist.

For (3), you have a ray defined by a point in the plane and the plane normal. Calculate the ray/cone intersection. Represent your ray as $p+dt$, where p and d are vectors.

Solve:

$\frac{x^2+y^2}{k^2}=z^2$

$\frac{(p_x + d_xt)^2+(p_y+d_yt)^2}{k^2}=(p_z+d_zt)^2$

$(p_x + d_xt)^2+(p_y+d_yt)^2 -k^2(p_z+d_zt)^2=0$

Simplifying and factoring out, we have a simple quadratic equation

$at^2+bt+c=0$

where

$a=d_x^2+d_y^2-k^2d_z^2$

$b=2(p_xd_x+p_yd_y-k^2p_zd_z)$

$c=p_x^2+p_y^2-k^2p_z^2$

Use the quadratic formula to solve

$t=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$

You will have either no solutions (the ray does not intersect the cone), one solution (the ray is tangent to the cone), or 2 solutions ( the ray intersects the cone in 2 places).

Next, you have to calculate the point of intersection and make sure it is within the region of the cone you want to project onto ($z \le height$) and ($z\ge 0$).

Finally, use the inverse of the transformation matrix you calculated to transform the point back into your original coordinate system.