Vectors and angles and math, oh my

This problem is a bit esoteric, and hard to explain without pictures, but I’ll give it my best shot.

We are given a plane in 3-space, specified by its normal vector and a point that it contains. An object-- say, a car-- is sitting upon the plane, such that its nose is pointing at a given compass heading.

What we want to find is the orientation of this object, using Euler angles-- roll, pitch, yaw. As noted above, the yaw is a given. How do we calculate an appropriate roll and pitch that allow the car to sit flush against the plane?

Looks to me as if the equations at ROTATION SEQUENCES AND EULER ANGLES might be useful; he even solves some of the systems.

Thanks for the link, but it’s a lot more general than what I’m looking for. I’m trying to find a specific algorithm, but it’s not

I’ve already coded the stuff that handles most everything to do with rotation. It all works as long as I have something that completely specifies the 3d rotation-- a matrix, a quaternion, a set of Euler angles, whatever.

The problem is that, in the situation I specified above, only the heading (yaw) is known. I have the normal vector of the plane I’m parallel to, but I have not been able to correctly use that to extract pitch and roll.

Come on, people… just because I’ve been a non-posting lurker for a few months is no reason to abandon me in my time of need! =b^)

Why don’t you just use the heading of the car on the plane and the spherical coordinate angles of the normal vector? I’m not sure if those work out to a standard set of Euler angles, but they’d be equivalent. Or are you looking for the formulae for converting a Cartesian vector to spherical?

Never mind, I’ve got a correct solution now; it’s decidedly sub-optimal, but it does work. I do cross products to find a pair of orthogonal vectors in the horizon plane, and the rotated vectors in the terrain plane; from there, obtaining each angle just involves a dot product and an arc-cosine.

If anyone’s interested, I’ll post the algorithm on the web someplace.

Never mind, I’ve got a correct solution now; it’s decidedly sub-optimal, but it does work. I do cross products to find a pair of orthogonal vectors in the horizon plane, and the rotated vectors in the terrain plane; from there, obtaining each angle just involves a dot product and an arc-cosine.

If anyone’s interested, I’ll post the algorithm on the web someplace.