I had seen OpenGL statement to draw a line using two points. However, my requirement is to draw a line using the following detail
- a point on a line
- Direction Vector
Im developing function in c++ using openGL library.
Any help is most appreciated.
I had seen OpenGL statement to draw a line using two points. However, my requirement is to draw a line using the following detail
Im developing function in c++ using openGL library.
Any help is most appreciated.
The answer depends on the semantics of what you've termed a direction vector.
In the computer graphics context I would normally take that term to mean a unit vector facing in the specified direction. Whereas in a mathematics context you might simply mean the relative vector that results from subtracting the two points' coordinates.
[Using P1 and P2 to represent the required two points, and V for the vector].
In the former case, you also need a specify a length for the vector, so you'll need:
P2 = P1 + n * V
whereas in the latter case, it's just trivially
P2 = P1 + V
Just make that two-point line a very long one, say 10000 to each direction from your point-on-a-line:
void drawLinePointDirection(Point P, Vector D) {
Point A = P + 10000*D;
Point B = P - 10000*D
drawLineTwoPoints(A, B);
}
assuming D is unit length.