Forum



Calculate the trajectory of an object...
16 replies



http://www.jbmballistics.com/ballistics/calculators/calculators.shtml
in such a system:
elastic collisions: by conservation of energy, the magnitude of the final velocity of each object must be equal to its initial velocity
perfectly inelastic collision: by definition, the objects stick together. since the center of mass will not move, the final velocity of both objects (in the center of mass frame) is zero.
(if you don't want to use the center of mass ref. frame, u'll have to solve a system of equations involving cons of momentum and cons of energy.)
ohh right u want a formula...
but u gotta tell us these first

# of dimensions
elastic/inelastic collision
what inputs this formula takes
I just want to get a vector when something (specifically a grenade) bounces off a wall.

it's pretty simple... i'm too lazy to write the formula for u
just draw some diagrams on a piece of paper and work from there.
if you give me more details about what exactly you plan to do (like custom grenades or whatever) i can help u write some code..
painted this

what this shows you:
the division of the distance to the wall through the "height" distance to the inpact point is the same for the incoming and the outgoing projectile/grenade.

Although the whole "alpha" and "beta" thing was awkward lol
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
if(map[obj.x+obj.xvel][obj.y]) { 	xvel = -xvel;//Horizontal Collision } if(map[obj.x][obj.y+obj.yvel]) { 	yvel = -yvel; }
Edit:
Could someone help me implement the Separating Axis Theorem into my game. I have written part of it, but now I am confused.
Edit again
Here is what I currently have written
just check if any of the vertices of rectangle1 are inside rectangle2.
u dont need to check for vertices of rect2 cuz that would be redundant
http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-res&trurl=http%3A%2F%2Fwww.flashxpress.net%2Fressources-flash%2Fla-detection-de-collision%2F&lp=fr_en&btnTrUrl=Translate
Dark Byte has written
It is needed to detect if rectangles that are at any rotation are colliding. http://www.gamedev.net/reference/programming/features/2dRotatedRectCollision/
http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-res&trurl=http%3A%2F%2Fwww.flashxpress.net%2Fressources-flash%2Fla-detection-de-collision%2F&lp=fr_en&btnTrUrl=Translate
http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-res&trurl=http%3A%2F%2Fwww.flashxpress.net%2Fressources-flash%2Fla-detection-de-collision%2F&lp=fr_en&btnTrUrl=Translate
Here's an implementation:
https://gist.github.com/729719
We find the necessary time/parameter in order for the parametrized normal line to reach the incidence between the edge and the tangent projection of each vertex onto the normal. This parameter's sign (+/-) should be uniform on a per edge basis.
Assuming negligible + constant time for struct index, arithmetic operation, and condition checks, the asymptotic complexity of this algorithm should on average be on an order of magnitude M*N where M is the number of vertices in polygon A and N the same in polygon B.



