Fuji 205 Report post Posted September 29, 2010 I've recently started a small project, but for some strange reason, my animation is failing me. My guess is that something is wrong with the function on how I'm trying to change the angle.var theta:Number; var h = 225 * Math.cos(theta); var k = 225 * Math.sin(theta); var animation = Timeline { repeatCount: Timeline.INDEFINITE; keyFrames: KeyFrame { time: 1s; action: function() { theta = Math.toDegrees(theta - 6); } } } 0 Share this post Link to post Share on other sites
karwosts 840 Report post Posted September 29, 2010 How is it failing you, what is wrong? What is it supposed to do?theta = Math.toDegrees(theta - 6);This looks all kinds of wrong. You have a theta value which I'd assume is in radians, you subtract 6 radians from it (that's a lot!), and then store it back in the same variable as degrees? Make sure this is what you mean to be doing. 0 Share this post Link to post Share on other sites
Fuji 205 Report post Posted September 29, 2010 I actually want it to decrease by 6 degrees, so that'd be the first place to start. Ideally, the orbiter should rotate 6 degree per second with its center being calculated based on theta. 0 Share this post Link to post Share on other sites
signal_ 366 Report post Posted September 29, 2010 If theta is in radians, and you'd like to subtract 6 degrees from it, you should first convert degrees to radians so that things are in the same units.Pi radians = 180 degrees. The conversion factor from degrees to radians is (PI/180), where PI = famous numerical constant. Google it for a precise value to define it as.So, to change 6 degrees into radians:deltaDegrees = 6.0;deltaRadians = 6.0 * PI / 180.0; // converts 6 degrees to radianstheta = Math.toDegrees(theta - deltaRadians);I don't know what you're using but perhaps there is a Math.toRadians(*) function? In any case you should work in degrees or radians, but not both. Furthermore in most languages inputs to trigonometric functions must be expressed as radians. 0 Share this post Link to post Share on other sites
Fuji 205 Report post Posted September 29, 2010 There is a toRadians, so I guess that's the way I'll have to go. You've given me enough to work with, so I'll see if I can get it working. 0 Share this post Link to post Share on other sites
Palidine 1315 Report post Posted September 29, 2010 Quote:Original post by FujiThere is a toRadians, so I guess that's the way I'll have to go. You've given me enough to work with, so I'll see if I can get it working.What? it's already in radians... why would you convert it again. convert it to degrees and THEN subtract six:This code:theta = Math.toDegrees(theta - 6);Subtracts 6 from theta which is in radians and then converts that value to degrees. Do the subtracting after the toDegrees conversion.-me 0 Share this post Link to post Share on other sites
Fuji 205 Report post Posted September 29, 2010 I see. The value I've been initializing with is still in degrees. I'll get that fixed. 0 Share this post Link to post Share on other sites