This site requires JavaScript, please enable it in your browser!
Greenfoot back
arucker90
arucker90 wrote ...

2011/10/12

computing sine and cosine in greenfoot

arucker90 arucker90

2011/10/12

#
I'm trying to set my variable (double) xVelocity to equal speed * cosine (angle) where speed and angle are declared variables. How do i enter that into greenfoot?
mjrb4 mjrb4

2011/10/12

#
You can use Math.cos and Math.sin:
xVelocity = speed*Math.cos(angle);
...similar with sine.
Kartoffelbrot Kartoffelbrot

2013/4/14

#
Thank you, too.
You need to login to post a reply.