I find myself needing to generate an 'example' triangle from a plane:
CPlane
{
Vec3 m_Normal;
float m_fConstant;
};
CTriangle
{
Vec3 a;
Vec3 b;
Vec3 c;
};
I know there are infinite possible positions of triangle on the plane, I just need to generate an 'example' triangle to define the plane for some 3rd party code, and it MUST NOT have duplicate corners (so the plane is undefined).
First point can just be the plane normal times the constant. For the 2nd and 3rd points I just need to move out from the first point along 2 axes (perpendicular? to the normal).
My first thoughts were, is it possible to use the 'reflection' approach in 3d:
i.e. in 2d
2, 1
can be reflected to
-1, 2
or 1, -2
to get vectors at 90 degrees
so then I was thinking about taking the normal and doing something like:
-y, x, -z
y, -x, -z
etc
Then I realised there could be problems e.g.
0, 0, 1
would generate
0, 0, -1 and
0, 0, -1
so both 'rotated axes' would be the same.
Is there a simple generalized solution to this problem, or would I need to use quaternions or matrices?