-
I cant get the sin cos to work in flash 5.
I write it like this
SinValue=Math.sin(angle);
CosValue=Math.cos(angle);
but its always different then what a calculator reads out to. Please help me...
-
I may be wrong, but I think that Flash works in radians. If you just plug something into your calculator without first changing it, it is reading in degrees. For example:
sin(30 degrees) = 1/2 (i think) while
sin(pi/6 rads) = 1/2
the conversion isn't that difficult.
radians = degrees*pi/180
so 45 degrees = pi/4
Should you need to convert rads back to degrees, just solve for degrees, it's not hard. If Flash does use degrees, then hey, at least you learned something new, right? Now you can brag to your friends that you know how to convert degrees to radians. Impress them.
-
That worked! Thanks for your help Minger, thats been bugging me for the last couple days.
-
here is something to tattoo to the back of your hand...or at least memorize:
degrees=radians*180/Math.PI
radians=degrees*Math.PI/180
you always need to use radians in flash's trig functions, but degrees for _rotation. a bit of a pain, but that's what we have.
-
here is something to tattoo to the back of your hand...or at least memorize:
degrees=radians*180/Math.PI
radians=degrees*Math.PI/180
Huh! I didn´t notice that flash wants Math.cos(x) -> x value in radians too, I thought I was going totally insane!
-
Which begs the question, can you define constants in Flash and if so, how?
I was pleasantly surprised that it swallows this without error:
Math.RAD2DEG = 57.29578;
Math.DEG2RAD = 0.01745329;
Is there a 'proper' way?
-
that's about as proper as it gets. Math is an object. you are assigning a property to an object. constants are usually in all caps.
you could get a little more accurate and say:
Math.RAD2DEG=180/Math.PI;
Math.DEG2RAD=Math.PI/180;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|