Am quite new to openGL and have tried my best to steer clear of any “complicated” maths. But i think i am going to have to dive in, so to speak.

My first question is basically what is a vector and a normal??

My program generates a tree and uses 3d lines. I would like to do some collision detection between the branches. But cant work out how to do it. I think i should do some vector maths but unsure.

Can some one please shed some light on this.

So just to round up my questions are:
Whats a vector and normal
How do i work out vector of a 3d line
What can i do with this (in ref collision)

Cheers, very much appreciated if someone could help

// 3D vector from a to b
vectorAB.x = b.x - a.x;
vectorAB.y = b.y - a.y;
vectorAB.z = b.z - a.z;

A normal vector is a perpendicular vector to a plane. It requires at least 3 points to determine a plane. Assuming you had a third point, c.

// 3D vector from a to c
vectorAC.x = c.x - a.x;
vectorAC.y = c.y - a.y;
vectorAC.z = c.z - a.z;

// Normal vector for plane containing points a, b, and c. Remember to normalize to magnitude of 1.
normalPlaneABC = crossProduct(vectorAB, vectorAC);
mag = magnitude(normalPlaneABC);
normalPlaneABC.x /= mag;
normalPlaneABC.y /= mag;
normalPlaneABC.z /= mag;

One normally doesn’t think of two lines as intersecting in 3D (okay for 2D though).

If you mean collision … that usually implies some sort of interaction between two planes or surfaces.

“My first question is basically what is a vector and a normal?”

One of the best sources for these kind of questions is the flipcode’s geometry primer. First part talks about vectors, second one is about lines ( and a lot of other things ):