d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help With Finding A Formula..
Add Reply New Topic New Poll
Member
Posts: 9,880
Joined: May 21 2009
Gold: 606.00
Apr 5 2013 06:12am
Given Distance, Gravity, air resistance, mass and initial velocity, create a formula for the angle required to launch an object at a target exactly 25,000 units away.

:bouncy: pls halp
Member
Posts: 9,880
Joined: May 21 2009
Gold: 606.00
Apr 5 2013 07:19am
Nevermind.

Angle = asin((Gravity * Distance) / Velocity^2)


Next question: How to compensate for differences in height
Member
Posts: 9,880
Joined: May 21 2009
Gold: 606.00
Apr 5 2013 06:33pm
Angle1 = atan( Velocity * Velocity + sqrt( Velocity * Velocity * Velocity * Velocity - Gravity * (Gravity * Distance * Distance + 2 * Height * Velocity * Velocity)) / Gravity * Distance)
Angle2 = atan( Velocity * Velocity - sqrt( Velocity * Velocity * Velocity * Velocity - Gravity * (Gravity * Distance * Distance + 2 * Height * Velocity * Velocity)) / Gravity * Distance)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 5 2013 09:00pm
Quote (Caleb7 @ Apr 5 2013 08:33pm)
Angle1 = atan( Velocity * Velocity + sqrt( Velocity * Velocity * Velocity * Velocity - Gravity * (Gravity * Distance * Distance + 2 * Height * Velocity * Velocity)) / Gravity * Distance)
Angle2 = atan( Velocity * Velocity - sqrt( Velocity * Velocity * Velocity * Velocity - Gravity * (Gravity * Distance * Distance + 2 * Height * Velocity * Velocity)) / Gravity * Distance)


that is one fucking ugly equation. try making use of the Pow() function to clean up all those `Velocity * Velocity * Velocity * Velocity` equations.

This post was edited by AbDuCt on Apr 5 2013 09:00pm
Retired Moderator
Posts: 38,135
Joined: May 27 2006
Gold: 3,835.50
Trader: Trusted
Apr 6 2013 01:21am
You can literally google the forumalas for these online

and as long as you have 1 day of coding and alegrab1 you can make the equation
Member
Posts: 9,880
Joined: May 21 2009
Gold: 606.00
Apr 6 2013 05:56am
Quote (ArtofApocalypse @ 6 Apr 2013 02:21)
You can literally google the forumalas for these online

and as long as you have 1 day of coding and alegrab1 you can make the equation


I was having trouble with what to search for. I kept getting formulas that only took in to account flat ground and not a difference in altitude. I found it though.

Quote (AbDuCt @ 5 Apr 2013 22:00)
that is one fucking ugly equation. try making use of the Pow() function to clean up all those `Velocity * Velocity * Velocity * Velocity` equations.


Yeah it is, lol. I didn't know how to do exponents in Expression 2 though, but turns out it's done like: Velocity^4

G =gravity() / tickrate
D = distance()
V2 = V^2
V4 = V^4
D2 = D^2
Radian1 = atan( V2 + sqrt( V4 - G * (G * D2 + Hoff * V2))) / G * D)
Radian2 = atan( V2 - sqrt( V4 - G * (G * D2 + Hoff * V2))) / G * D)
Angle1 = (Radian1 * 180) / pi()
Angle2 = (Radian2 * 180) / pi()

Did it like this and I can see exactly what's happening now

Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 6 2013 09:52am
Quote (Caleb7 @ Apr 5 2013 09:19am)
Next question:  How to compensate for differences in height


pencil and paper bro. 10th grade physics

1/2 * a t^2 + vt + x = 0

that'll give you the time it takes assuming you land at the same spot
you can use this time and v_horiz to determine how far you'll travel on level ground
for height differences, it's a different subproblem. break it down first until it's level.



use one of those two to determine initial velocity given the distance and final velocity

This post was edited by carteblanche on Apr 6 2013 09:54am
Member
Posts: 9,880
Joined: May 21 2009
Gold: 606.00
Apr 7 2013 03:29am
Quote (carteblanche @ 6 Apr 2013 10:52)
pencil and paper bro. 10th grade physics

1/2 * a t^2 + vt + x = 0

that'll give you the time it takes assuming you land at the same spot
you can use this time and v_horiz to determine how far you'll travel on level ground
for height differences, it's a different subproblem. break it down first until it's level.

http://www.physicsclassroom.com/Class/1DKin/U1L6a1.gif

use one of those two to determine initial velocity given the distance and final velocity


What i posted above solves height difference
And i have never taken physics, so..
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll