The general problem is projecting a polygon onto a plane is widely solved, but I was wondering if anybody could make some suggestions for my particular case.
I have a planar polygon P in 3-space and I would like to project it onto the plane through the origin that is orthogonal to the unit vector u. The vertices of P and the coordinates of u are the only data I have (all w.r.t. the standard basis of R^3).
However, I don’t just want the projected coordinates. I actually would like to find an orthonormal basis of the plane orthogonal to u and to then find the coordinates of the projected vertices in this new basis.
The basis itself doesn’t matter so long as it is orthonormal. So really I need to do two things within the framework of the GNU Scientific Library:
(1) Find two orthonormal basis vectors for the homogeneous plane orthogonal to the unit vector u.
(2) Find the coordinates in this basis of the projection of P’s vertices onto the plane.
Any ideas on how to do this using gsl?
I haven’t used GSL, but you only need to use dot-product, cross-product, and normalizing to get the result.
(1) Pick any vector r that is not a multiple of u. Let v = the normalized cross-product of r and u. Let w = the cross-product of u and v. Your orthonormal basis vectors are v and w.
(2) To project a vertex a to this plane, it’s (a dot v) * v + (a dot w) * w. (The v coordinate is a dot v, the w coordinate is a dot w)
To help think about how this works, choose u = <1,0,0> and r = <3,0,5> to start, and visualize the 3-d vectors.