Sagekilla
14th December 2009, 06:28
Hi all, this is partially a math question and partially a openGL question.
I have two sets points: A(x1, y1, z1) and B(x2, y2, z2). I need to create two points (P(x3, y3, z3) and Q(x4, y4, z4)) for the base of the arrow head given these two points.
From there I can simply do my openGL calls:
glBegin(GL_LINES);
glColor3f(1, 1, 1);
glVertex3f(x1, y1, z1);
glVertex3f(x2, y2, z2);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(1, 1, 1);
glVertex3f(x2, y2, z2);
glVertex3f(x3, y3, z3);
glVertex3f(x4, y4, z4);
glEnd();
Except for the fact that I'm having a hard time finding a decent algorithm to do this. I need something reasonably fast because I'll be recomputing the arrows points (P, Q) on every Draw() call I make.
Any help is much appreciated!
I have two sets points: A(x1, y1, z1) and B(x2, y2, z2). I need to create two points (P(x3, y3, z3) and Q(x4, y4, z4)) for the base of the arrow head given these two points.
From there I can simply do my openGL calls:
glBegin(GL_LINES);
glColor3f(1, 1, 1);
glVertex3f(x1, y1, z1);
glVertex3f(x2, y2, z2);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(1, 1, 1);
glVertex3f(x2, y2, z2);
glVertex3f(x3, y3, z3);
glVertex3f(x4, y4, z4);
glEnd();
Except for the fact that I'm having a hard time finding a decent algorithm to do this. I need something reasonably fast because I'll be recomputing the arrows points (P, Q) on every Draw() call I make.
Any help is much appreciated!