[ODE] End point of a Ray

Aras Pranckevicius nearaz at gmail.com
Wed Oct 12 16:19:58 MST 2005

> void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir);
> Get the starting position (start) and direction (dir) of the ray. The
> returned direction will be a unit length vector.

Well, it is an unbounded ray (not a segment) - it has a start position
and a direction; and conceptually it extends to infinity.

> Now I need to calculate the second point (end point)

You don't do that. It does not have an end point (unless you somehow
decide where it should end - e.g. somehow know what length do you

> norm = sqrt(dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]);
> pos2[0] = dir[0]*length/norm + pos1[0];

No need for such complexity: norm will always be 1 (the direction is
normalized - a unit length vector). So, if you somehow know the needed
length, you just do:
  pos2[0] = pos1[0] + dir[0]*length;
  pos2[1] = pos1[1] + dir[1]*length;
  pos2[2] = pos1[2] + dir[2]*length;

Aras 'NeARAZ' Pranckevicius
http://nesnausk.org/nearaz | http://nearaz.blogspot.com

More information about the ODE mailing list