Point project onto plane - math

Given a p point(3D) and a plane(contain a base point and a normal vector), how should I project point onto plane?
Details:
Point p is a 3D vector(x1,y1,z1), and plane is represent by a point q at the plane and a 3D normal vector l(x3,y3,z3). All data is defined and no camera projection. The task is to project p onto the plane, return its new position(x1',y1',z1').

Related

projecting points onto the sky

If I had a sphere with unit radius, and I had some points defined as latitudes and longitudes on that sphere, and I had a camera defined with a vertical and horizontal field of view angle which is always in the centre of the sphere. How can I project these points onto that camera?
A point at direction (x,y,z) at infinity has homogeneous coordinates of (x,y,z,0). So assuming that you use a typical view-projection matrices to describe your camera model, it is as simple as calculating
P * V * ( cos(lon)*cos(lat), sin(lon)*cos(lat), sin(lat), 0 )'
and then proceeding with a perspective divide and rasterization.

How to get world-space coordinate of a point in SDF function?

How can a world-space coordinate of a point in Signed Distance Field be obtained?
Example: Let there be a Signed Distance Field function of e.g. a cone sitting on top of a box. Assuming I perform transformations on the cone such as scaling, translation and rotation, how can I get the world-space coordinate of e.g. the tip of the cone?
When using polygonal geometry, I would query the world-space position of the vertex that represents the tip of the cone (after performing all transformations to the polygonal model). However, when using SDFs, I don't know how to proceed.

Converting points on a 3D plane to a 2D coordinate system w.r.t. camera

Please kindly redirect me if this is a repeated question:
Currently I have some points in 3D space projected on a plane, and I would like to convert it to 2D wrt the camera angle/view matrix I am currently at. For instance, the 3D coordinates on the YZ plane are (0,1,4) and (0,4,2), so the change in z is -2. However, I want to flatten this and achieve a change in z of 0. Any help or comments are appreciated!

finding the rotation axis

I'm using eigen library to rotate a plane to be parallel to the ground plane.
The ground plane is defined using the normal vector (0,0,1)
The target plane is a set of 3D points and a normal
The rotation angle is known
the normal vector of the plane as well as every point on that plane has to be rotated to be parallel to the ground plane
I'd like to use affine transformation from
http://eigen.tuxfamily.org/api/TutorialGeometry.html
something like this
Transform t = AngleAxisf(a,axis);
axis in this case is a matrix representing an arbitary axis, along which the rotation takes place.
How to find this axis?
Many thanks
Making two planes parallel can be done by making their normals parallel, so you just need to find the axis to rotate the target plane normal about. This is just the axis that is perpendicular to both your ground plane normal and your target plane normal which can be found using the cross product. In your case, if your target plane has a normal of [x,y,z], then the rotation axis is [y,-x,0].

Projection matrix point to sphere surface

I need to project a 3D object onto a sphere's surface (uhm.. like casting a shadow).
AFAIR this should be possible with a projection matrix.
If the "shadow receiver" was a plane, then my projection matrix would be a 3D to 2D-plane projection, but my receiver in this case is a 3D spherical surface.
So given sphere1(centerpoint,radius),sphere2(othercenter,otherradius) and an eyepoint how can I compute a matrix that projects all points from sphere2 onto sphere1 (like casting a shadow).
Do you mean that given a vertex v you want the following projection:
v'= centerpoint + (v - centerpoint) * (radius / |v - centerpoint|)
This is not possible with a projection matrix. You could easily do it in a shader though.
Matrixes are commonly used to represent linear operations, like projection onto a plane.
In your case, the resulting vertices aren't deduced from input using a linear function, so this projection is not possible using a matrix.
If the sphere1 is sphere((0,0,0),1), that is, the sphere of radius 1 centered at the origin, then you're in effect asking for a way to convert any location (x,y,z) in 3D to a corresponding location (x', y', z') on the unit sphere. This is equivalent to vector renormalization: (x',y',z') = (x,y,z)/sqrt(x^2+y^2+z^2).
If sphere1 is not the unit sphere, but is say sphere((a,b,c),R) you can do mostly the same thing:
(x',y',z') = R*(x-a,y-b,z-c) / sqrt((x-a)^2+(y-b)^2+(z-c)^2) + (a,b,c). This is equivalent to changing coordinates so the first sphere is the unit sphere, solving the problem, then changing coordinates back.
As people have pointed out, these functions are nonlinear, so the projection cannot be called a "matrix." But if you prefer for some reason to start with a projection matrix, you could project first from 3D to a plane, then from a plane to the sphere. I'm not sure if that would be any better though.
Finally, let me point out that linear maps don't produce division-by-zero errors, but if you look closely at the formulas above, you'll see that this map can. Geometrically, that's because it's hard to project the center point of a sphere to its boundary.

Resources