Difference between revisions of "findProjectileTrajectory"

(Yay! Projectile finding thingy.)
 
m (Added missing property for the category page, removed superfluous section.)
 
Line 11: Line 11:
 
end
 
end
 
</source>
 
</source>
 
== Contributors ==
 
* [[User:Substitute541|Substitute541]]
 
  
 
[[Category:Snippets]]
 
[[Category:Snippets]]
 
{{#set:Author=User:Substitute541}}
 
{{#set:Author=User:Substitute541}}
 +
{{#set:LOVE Version=any}}
 
{{#set:Description=Finds a projectile's position at a certain time}}
 
{{#set:Description=Finds a projectile's position at a certain time}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|findProjectileTrajectory}}
 
{{i18n|findProjectileTrajectory}}

Latest revision as of 00:33, 12 November 2016

Finds a projectile's position at a certain time.

Variable Definitions : ri = initial position {x, y} ; vi = intial velocity {vx, vy} ; g = gravity {gx, gy} ; t = time

-- This assumes that ri, vi, and g are put in the {x, y} notation
function findProjectileTrajectory(ri, vi, g, t)
	local rfx = ri[1] + vi[1]*t + (g[1] * t^2)/2
	local rfy = ri[2] + vi[2]*t + (g[2] * t^2)/2
	return rfx, rfy
end


Other Languages