   Calculating Absolute Position in 2d plane
// note to all non-javascripters, var is like a float in this casefunction calculate() {//DISTANCE CALCULATIONvar speed = velocity.value;var angle = artangle.value;var vx = Math.cos(angle * (Math.PI/180)) * speed;var vy = Math.sin(angle * (Math.PI/180)) * speed;var  t = 2 * vy / 9.81;var  d = vx * t;if (d < .01) { d = 0; }alert("distance = " + d);collisionDetect(vx*t);}given Angle    = 30 degrees and Velocity = 45 m/sX-Velocity = cos(30) * 45m/s = 38.95 m/sY-Velocity = sin(30) * 45m/s = 22.5 m/stime  = 2*( 22.5m/s / 9.81m/s^2 ) = 4.59sdistance(along x-axis)   = 38.97m/s * 4.59s= ((178.87 m))distance after 1 ms(along x-axis) = 178.87/(4.59)*1000 = .003897mdistance after 1 ms(along y-axis) = ?????  In my example, the projectile has travelled .003897 meters along its x-axis in one millisecond, how can I find its value along the y-axis after 1 millisecond?Any help would be greately appreciated, thanks![edited by - MrPoopypants on August 2, 2003 1:16:16 AM]
  y(t) = -4.9t2 + vt + sYou input a time, initial velocity, and initial height.  You only have a y-velocity (sin(angle) * speed) and I assume your initial height is 0, however you can''t calculate the time because you''re in the process of trying to calculate something out.So before I go any further, what exactly are you trying to do, and what information do you already have? ;  Use the happiness of calculus!  If you double-integrate the acceleration due to gravity, -9.8 m/s².  This is what you get:d²y/dt² = -9.8   <- accelerationdy/dt = -9.8t + c<- velocityy = -4.9t² + ct + d   <- y positionWhere c and d are constants of integration and c = initial velocity (v0 if you will) and d = initial height in meters.  So what you need is this equation:y = -4.9t² + v0t + hPlug in a time and it will give you the height.  Hope this is what you wanted!  Learn calculus, it heals you!;quote:Original post by Lord Garibaldi   Use the happiness of calculus!  If you double-integrate the acceleration due to gravity, -9.8 m/s².  This is what you get:d²y/dt² = -9.8   <- accelerationdy/dt = -9.8t + c<- velocityy = -4.9t² + ct + d   <- y positionWhere c and d are constants of integration and c = initial velocity (v0 if you will) and d = initial height in meters.  So what you need is this equation:y = -4.9t² + v0t + hPlug in a time and it will give you the height.  Hope this is what you wanted!  Learn calculus, it heals you! edit: Nevermind, i think i slightly understand it now...ok so y = -(.5g) + velocity (what does the 0 mean?) * time + height  [edited by - MrPoopypants on August 2, 2003 1:03:19 PM];quote:Original post by Zipster  So before I go any further, what exactly are you trying to do, and what information do you already have?   I''m trying to find the projectiles height (value of y-axis) after 1 millisecond given distance on x-axis, angle at which projectile is fired, and velocity at which projectile is fired;quote:I''m trying to find the projectiles height (value of y-axis) after 1 millisecond given distance on x-axis, angle at which projectile is fired, and velocity at which projectile is firedIf you''re trying to find the height of the projectile then first thing you need to know is that the distance on the x-axis is absolutely irrelevant. (unless you are using that to determine the time that has passed, and then using that time value to determine the height, which is a very roundabout way of doing it and i don''t recommend it)Given the angle at which projectile is fired and initial velocity Vo, you must use trig to calculate the initial velocity in the vertical direction (Vyo), which you seem to have done.The other guys have given you the correct formula.H = -4.9*(t^2) + Vyo*t + Ho.quote:(what does the 0 mean?)Basically it is a subscript zero indicating the "initial" value of a variable.  Vo is initial velocity, Vyo is initial velocity in the y-direction, Ho is the intial height. 