OK, let me tell you the whole history.
I need to create a circle using the current position of the “coordinate axes” (base vectors of the coordinate system) of the model-view matrix, I mean, you can do a lot of rotations and translations and then create a circle in the current position of the coordinate axes.
To create the circle I use the following formula for the XY plane
glVertexd(cos(x) * radius, sin(y) * radius, 0);
As you can see I’m working with only two coordinates and it’s OK. The problem arises when I do some rotations to draw the circle in a different plane, in this case I need to set every circle’s point in the three coordinates (x, y, z) but I only have the cos(x) and sin(y) so I need to know what’s the value of Z for each point.
That’s why I say that I’ve a plane (the plane where the circle will be drawn) so having a plane I just need to refer to a point in that plane as (X, Y) but I want to know where it’s exactly located in the default OpenGL’s coordinate system, I mean the equivalent position of that point for the identity matrix of the model-view.
The main idea is to do all the rotations and translations to easily locate and create the circle (and the other types of shapes) but create their vertices referring to the Gl’s identity matrix so every time I need to render the scene I don’t have to change the GL’s model-view matrix to render each object.
So resuming what I need?
I need a function that receive the two coordinates of a point in the current plane and it returns the three coordinates for that point respect to the GL’s identity matrix for the model-view.
Something like this:
struct Vector3
{
double x, y, z;
};
Vector3 PutPixelInPlane(point_PosX_inPlane, point_PosY_inPlane)
{
// Get the base vectors from the current Model-View matrix
// Calculate the plane that intersect each base vector at 1 unit
// Return the position of the point at point_PosX_inPlane, point_PosY_inPlane respect to the Gl's identity matrix coordinate system
}
Of course, if there’s another way to do it let me know. This is just the way I see to solve the problem.
Thank you.