Search code examples
actionscript-3rotationpapervision3d

360 rotation degrees to 2d object from 3d papervision object in actionscript


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.


Solution

  • 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?