Project a Vector3 onto a plane, orthographically

How would I go about doing this? I have a Vector3 point, and a Vector3 normal defining the plane’s direction. When I google this, I find an awful lot that takes projection into account, and camera stuff. But I don’t need this for anything visual. I just need to convert from 3D to 2D.

If I was using Vector3.up, this would be easy; I would just 0 out the Y coordinate. But if I have a normal like (0.8, 0.1, 0.1), I don’t know what to do.

Ultimately, I want to project four vectors from 3D space to 2D space so I can perform a line segment intersection test on them in 2D.

You simply project your vector onto the normal and subtract the result from your original vector. That will give you the projected vector on the plane. If you want to project a point to a plane you first need to calculate the relative vector from a point on that plane.

Vector3 planeOrigin;
Vector3 planeNormal;
Vector3 point;

Vector3 v = point - planeOrigin;
Vector3 d = Vector3.Project(v, planeNormal.normalized);
Vector3 projectedPoint = point - d;

Your Vector3 represents a point in world-space, and you want to project it directly onto a plane ?

so say,

vP = the Vector3 of the point on the plane.

vN = the Vector3 of the normal of the plane.

vQ = the Vector3 of the point you want to project.

create a new vector, vPQ that’s the vec from vP to vQ:
vPQ = vQ - vP.

now project vPQ onto the normal:
dot = vPQ DOT vN.
vQN = vN * dot.

vQN is now the projection of your point onto the normal.
now we subtract vQN from vQ to pull that vec down onto the plane:

vAnswer = vQ - vQN.