开发者

Angles to decimal conversion

I'm trying to understand some flash animation, and am having difficulty working out the following. Can anyone help?

I want to convert a degree range of 0 to 90, to a value between 0 and 1

These is an existing function to convert from the range 0 to 1 to degrees, eg:

function convertToDegrees(Int:Pos)
{
    var rot = (45 * pos);  
    var degrees = (90 - ( rot * 2 ));  

    return degrees;
}

Now to convert backwards, from degrees to 0 to 1 value, I am trying: 开发者_如何学运维(WHICH IS WRONG)

function convertFromDegrees(Int:currentDegreeValue )
{
    var rot =  (currentDegreeValue / 2) + 90;  
    var Pos = rot / 45;

    return Pos;  
}

Can anyone help me as to where I am going wrong?


The first function could be simplified to 90 * (1 - pos), so the reverse function would be 1 - (degrees / 90).


I want to convert a degree range of 0 to 90, to a value between 0 and 1

How about:

x / 90.0


rot = (90 - degrees) / 2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜