I am not aware of a function in OSG to do this, however, you can do it yourself.
If you have a starting point and direction for each line, you can define each line parametrically as Line 1: P + rA Line 2: Q + sB where P,Q are the starting points and A,B are the unit direction vectors. The scalars r,s are what we want to solve for. This can be done by equating the two lines P + rA = Q + sB or rA - sB = Q - P For 2D, this is a simple 2x2 linear system. The scalars r,s can be uniquely solved for by using Cramer's rule (stable for small systems). Of course, this assumes that the lines are not parallel or on top of each other (check for this first). Once the scalars r,s are solved for, plug them back into Line 1 or Line 2 to get the point of intersection in your coordinate system. For 3D, the system above turns into an overdetermined system of equations (i.e. 3 equations and 2 unknowns) which does not have a solution except when the system contains linearly dependent equations. For the case where there is no solution, you can solve for a point of intersection in a least squares sense using the method of normal equations. This method is numerically stable for small systems. To do this, write the system above as Cx = d where C is a 3x2 matrix, x is a 2x1 column vector containing the scalars r,s we want to solve for, and d is 3x1 column vector. Using the method of normal equations, we can rewrite the system to be CtCx = Ctd where Ct is the transpose of C. This new system now becomes a 2x2 linear system which can be solved like the 2D case above. Hope this helps... -Shayne ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42509#42509 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

