Lets say I have point (x,y,z) and plane with point (a,b,c) and normal (d,e,f). I want to find the point that is the result of the orthogonal projection of the first point onto the plane. I am using this in 3d graphics programming. I want to achieve some sort of clipping onto the plane.
The projection of a vector on a plane is its orthogonal projection on that plane. The rejection of a vector from a plane is its orthogonal projection on a straight line which is orthogonal to that plane. Both are vectors. The first is parallel to the plane, the second is orthogonal.
Orthogonal projection of a point is the process of finding a point on a curve or a surface such that the vector connecting the point in space and the point on the curve or the surface becomes perpendicular to the curve or the surface.
x = x0 + a · t, y = y0 + b · t and z = z0 + c · t, These variable coordinates of a point of the line plugged into the equation of the plane will determine the value of the parameter t such that this point will be, at the same time, on the line and the plane.
The projection of a point q = (x, y, z)
onto a plane given by a point p = (a, b, c)
and a normal n = (d, e, f)
is
q_proj = q - dot(q - p, n) * n
This calculation assumes that n
is a unit vector.
I've implemented this function in Qt using QVector3D:
QVector3D getPointProjectionInPlane(QVector3D point, QVector3D planePoint, QVector3D planeNormal) { //q_proj = q - dot(q - p, n) * n QVector3D normalizedPlaneNormal = planeNormal.normalized(); QVector3D pointProjection = point - QVector3D::dotProduct(point - planePoint, normalizedPlaneNormal) * normalizedPlaneNormal; return pointProjection; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With