Forum

> > Off Topic > Calculate the trajectory of an object...
Forums overviewOff Topic overviewLog in to reply

English Calculate the trajectory of an object...

16 replies
To the start Previous 1 Next To the start

old Re: Calculate the trajectory of an object...

FlooD
GAME BANNED Off Offline

Quote
generally, the easiest method is to transform to the center of mass reference frame.

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

old Re: Calculate the trajectory of an object...

Lee
Moderator Off Offline

Quote
I'd recommend talking to FlooD for this one. He's smarter than our entire class of physics students throwing money away at an overpriced and completely useless ivy degree

old Re: Calculate the trajectory of an object...

FlooD
GAME BANNED Off Offline

Quote
hm this seems more related to programming than physics so i'd recommend talking to lee

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..

old Re: Calculate the trajectory of an object...

Flacko
User Off Offline

Quote
In case you're using "xvelocity and yvelocity" style instead of an angle, the thing get's a lot easier because you only need to use the unary minus with the corresponding axis velocity.
1
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;
}

old Re: Calculate the trajectory of an object...

archmage
User Off Offline

Quote
Well actually I am using an angle, but I will use an vector for the velocity to make this simpler (and hopefully more efficient).

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
More >

old Re: Calculate the trajectory of an object...

FlooD
GAME BANNED Off Offline

Quote
hm i just read the wikipedia article for that axis theorem and i dont see how it is necessary for rectangles...

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

old Re: Calculate the trajectory of an object...

Lee
Moderator Off Offline

Quote


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.
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview