   Problem with calculating the apex of a trajectory
  Hello, i am not very competant with physics/trig and i am trying to calculate the max height the projectile in my program will reach. In my book i have the following formula:height = (V²sin²Angle)/(2g)where V is initial velocity, Angle is angle upon launch and g is gravity.When i try to code this i get problems squaring sin saying it is illegal. I have the following code:int sQ = speed*speed; //initial velocity squaredint sinSq = pow(sin,2); //sin squared?maxHeight = (sQ * (sinSq *angle) / (2*gravity)); //work out apex of trajectoryAm i using this formula the right way?Thanks in advance   
  The formula is, in fact, (V sin Angle)2 / 2g   ;Quote:Original post by edd1986Hello, i am not very competant with physics/trig and i am trying to calculate the max height the projectile in my program will reach. In my book i have the following formula:height = (V²sin²Angle)/(2g)where V is initial velocity, Angle is angle upon launch and g is gravity.When i try to code this i get problems squaring sin saying it is illegal. I have the following code:*** Source Snippet Removed ***Am i using this formula the right way?Thanks in advancesin is a function, so what does this pow(sin,2) mean? Did you mean pow(sin(angle),2)?   ;Quote:Original post by vNistelrooyQuote:Original post by edd1986Hello, i am not very competant with physics/trig and i am trying to calculate the max height the projectile in my program will reach. In my book i have the following formula:height = (V²sin²Angle)/(2g)where V is initial velocity, Angle is angle upon launch and g is gravity.When i try to code this i get problems squaring sin saying it is illegal. I have the following code:*** Source Snippet Removed ***Am i using this formula the right way?Thanks in advancesin is a function, so what does this pow(sin,2) mean? Did you mean pow(sin(angle),2)?I wasn't really too sure what i meant, was just going by my book. Thank you ToohrVyk :);  Hi again, i'm getting quite confused. What my program is doing is firing off a firework projectile at a set angle and calculating the projectile motion. I thought i had this task completed until i tried changing the angle at which i fired off the projectile.Example: i have a projectile with an inital velocity of 50, shot off at 60degreesto work out the velocities of the x and y components i understand i have to do the following:vel.x = 50*cos(60)vel.y = 50*sin(60)when i do this i get results of v.x = -47 and v.y = -15 when the tutorial website i am looking at says v.x should be 25 and v.y should be 43.Here is my code for working out velocities of each component:int initVel = 50;int angle = 60;particle->vel.x = initVel*cos(angle); particle->vel.y = initVel*sin(angle);The only time i seem to be able to get (seemingly) realistic projectile motion is when the angle is 45 degrees. This is really confusing me. any more help would be greatly appreciated.   ;  sin and cos need their argument to be expressed in radians, not degrees. The conversion factor is: RADIANS = DEGREES * (PI / 180)   ;  You're doing most things correct, but your angles aren't what you think they are.  The trig functions are expecting radians instead of degrees.  In this case, you need to do an explicit conversion of your numbers.  Something like these conversions:degrees to radians:  rads = (angle_in_degrees) * (pi / 180.0)radians to degrees:  degs = (angle_in_radians) * (180.0 / pi)For more info, google "degrees to radians".  There's a few thousand years worth of explanations out there.*   ;  thank you so much. i thought it would be something very simple :)   