# [ODE] Rotating dRayClass?

Kyle Hubert khubert at gmail.com
Sat Sep 16 16:04:56 MST 2006

```Not quite. My camera does point down along the zaxis, but I'm trying
to do picking, which means I'm using the cursor. I suppose I could of
used OpenGL's methods for picking, but I felt up to the challenge of
doing it with ray casts. I took my camera rotation matrix (which I had
to create because I was using just Euler angles passed to glRotatef)
and multiplied it by the point in the viewport the user clicked on.
This worked. Thanks for your suggestion Roland, it led me down the
right path.

I did something like:
Vector v = cameraRotationMatrix * "the direction vector in the viewport";
dGeomRaySet(ray, rayPos.x, rayPos.y, rayPos.z, v.x, v.y, -v.z);

I do have two things to figure out, one is I have to negate the z
value. Two is, I have to negate the angles giving me the rotation
matrix.

Thanks again.

-Kyle

On 9/16/06, Roland Kindermann <iyo at gmx.de> wrote:
> Hi,
> dGeomSetQuaternion or dGeomSetRotation might do but I never tried them
> on a ray.
> You probably have a rotation matrix for your camera. Assuming that you
> camera points along the z axis in its unrotated state you could do
> something like:
> Vector v = cameraRotationMatrix * Vector(0, 0, 1);
> dGeomRaySet(ray, rayPos.x, rayPos.y, rayPos.z, v.x, v.y, v.z);
> Cheers,
> Roland
>
> Kyle Hubert schrieb:
> > How can I rotate my dRayClass? In particular, I am using the Ray for
> > selecting(picking) physics objects based on the user's viewport. I
> > have it working nicely for when the "camera" is placed at a location
> > with no rotation. Now, when I rotate the camera the point of
> > intersection of the ray (the origin hasn't moved) should be rotated.
> > Is their an easy way to do this? Like call dGeomRaySet then call
> > dGeomSetRotation?
> >
> > Thank you.
> >
> > -Kyle
```