views:

147

answers:

2

hi,i am 2D game how can i calculate angle to reach particular height? suppose i want height 320.time is increasing as 0.1. i am using h = (u sin(angle))^2 / 2g; where can i put the time?

+1  A: 

The inverse of the sin() function is called the arcsine, or sin-1 in mathematical notation. In many programming languages, it's available as asin().

unwind
but to caluculate asin() ,value must be within 1.....!!!!!!!!
Mikhail Naimy
A: 

From my answer to your previous question:

Where y is the height you want to reach (320 in this case), and assuming you're starting at y=0:

angle = arctan( 2*y / x )

where x is the distance on the X-AXIS between your starting point and the point where you want to reach that height, which is necessary in order to specify an angle.

If you really want me to, I can derive this one for you, but it follows directly from my answer to your previous question.

Also (since I can't comment answers yet I'm saying this here), you may be having issues getting an angle "less than 1" because you're trying to use degrees instead of radians. Many math libraries work in radians, so convert your angles.

giogadi