views:

301

answers:

1

Hey guys,

Some reason I've been struggling with this for a while.

I have a papervision camera of which turns using keyboard input, I have a radar of which I would like to orientate to direction when the camera turns.

I have it all working apart from mapping my (camera) DisplayObject3D.rotationY to RadarInterface.rotation correctly.

The camera (or any 3d object) works with values I'm finding hard: Clockwise: 0 to 89, 89 to 0, -0 to -89, -89 to -0 doing a complete 360.

So if I were to turn 180 degrees I'd go from 0 to 90 and back down to 0 again.

Does anyone know how to convert this to 360 degrees.

Thanks in advance.

A: 

It isn't exactly clear to me how these numbers you have given would work. In the past I've had rotation problems with objects spinning incorrectly due to flash changing 270 to -90 or something like that. The statement below has help me with this a few times; it changes the range from 0 to 360 to -180 to 180.

if (Math.abs (difference) > 180) {
    difference = difference > 0 ? difference - 360 : 360 + difference;
}

Are you saying that 45 degrees would return the same value as 135?

danjp
Beautiful. This coupled with me changing the formule to work with localRotationY instead of just rotationY worked.rotation is a degree corrected value, but localRotation is constant. It'll go from 0 to 360 + without reseting to 0 - so if you would turn twice it would read 720 instead of zero.
Glycerine