# The angle between two 3D lines

1. Jul 5, 2006

### somy

Can anyone tell me how can I calculate the angle between two lines in 3D. I need in my codings.
I know it has a simple solution. but I really have mixed up!!!
Thanks.

2. Jul 5, 2006

3. Jul 6, 2006

### HallsofIvy

If the two lines actually intersect, then the angle is given by
$$cos(\theta)= \frac{u\cdot v}{|u||v|}$$ where u and v are any vectors pointing in the direction of each line. You can use the point of intersection and one point on each line to define those vectors.

If the line do not intersect (the "typical" case in 3d) then there is no angle between them.

Last edited by a moderator: Jul 6, 2006
4. Jul 6, 2006

### somy

Thank you. I'll try it!!!