Hey all, got a question for anyone who knows something about integrators (specifically Verlet, but any should do). I'm having problems with my Point to Line Collision response (code below). Basically if you draw two points with a mass over 0 (0 represents static elements in my implementation) and connect them with a rigid connector (the wooden stick button) then place a static point (circle with a red dot in it) below that and step through you will notice that the line does not react as you would expect. Instead of falling off to the side with the most mass its falling upwards to the side with the least mass :(.

One other problem I'm having is that is seems that Mass is not affecting integration properly. I can have two points one with a very high mass and one with a lower mass collide. You would expect that the higher mass would tend to stay more on its existing path while pushing the lower mass more in the opposing direction, instead they are both affected equally.

Just in case a few screen shots would help, below is a series of 4 shots (left to right, top to bottom) showing just before collision, the initial collision, a few steps further, and even further. As you can see, you would expect the bar to drop right and down, but instead its moving left and up.

http://www.eonclash.com/physics/ver_prob.jpg

paul_nicholls

29-07-2009, 03:44 AM

hmmm....Have you read this article about using Verlet with character physics?

http://www.teknikus.dk/tj/gdc2001.htm

You probably have, but I will post it anyway :)

cheers,
Paul

jdarling

29-07-2009, 01:45 PM

Yep, read that article several times.

In fact, I managed to figure out what my problem is, just can't figure out how to solve for it. The basic issue is that when a point (p) moves past a segment (s) it is moved to the "corrected path". But p's last position isn't updated properly so that the verlet system can utilize the last position to create the next frames movement vector.

Need to figure out a way to calculate angle of incidence and angle of reflection using vectors instead of algebra :(. Also need to find the proper last position for p using vector math. If I have time I'll post up an image showing what I'm talking about.

- Jeremy

jdarling

29-07-2009, 07:21 PM

Ok, here is a quick capture of two simulations that show the problem better. On the left is a single particle striking a static bar and bouncing in the wrong direction. Given the angle of the line you would expect it to follow (sort of) the green arrows, instead it follows the red (as seen).

The right contains a bar falling and striking a single point. Instead of the right side of the bar moving upwards with the left continuing downward (as expected and shown with the green and blue arrows) it always moves up and left. No matter what every time a bar and a point collide the result is to move left :(.

looks susopicious to me (units don't match :)). Since the force acting on the item is multiplied by its mass, the acceleration ( calculated in the TVerletItem.Integrate procedure) is the same for all items. That is why mass does not affect the motion.
I think You should remove multiplication by mass.

jdarling

30-07-2009, 01:51 AM

I think you might be misreading the code;

The initial Item.Force = Force * Item.Mass calculation is using the global force to perform a scale on the local mass of the object.
Thus presenting a basic force vector to representing basic gravity (if in affect).
Then inside of the item.gatherforces all other local (constraint) forces are added to this initial value.
Integrate utilizes this final force along with the objects mass, last-position, and the time-step to calculate the actual movement of the object for the frame.

Of course, that's if I understand the theory properly :)

jdarling

30-07-2009, 03:10 AM

Oh wait, I'm an idiot who misread the theory LOL. Your right, the division by mass inside the integration step isn't necessary. By removing it you get proper reaction of a V2=M1*2*V1 (or an object with twice the mass should have twice the velocity as another object).

Ok, well that fixes that. Now, back to the problem of the bouncing balls and sticks :(

paul_nicholls

30-07-2009, 03:37 AM

Oh wait, I'm an idiot who misread the theory LOL. Your right, the division by mass inside the integration step isn't necessary. By removing it you get proper reaction of a V2=M1*2*V1 (or an object with twice the mass should have twice the velocity as another object).

Ok, well that fixes that. Now, back to the problem of the bouncing balls and sticks :(

Good to see you got that bit working :)

Now back to reflection rays you were wanting...

Here is the code I use in my raytracer for calculating a reflection ray, and it doesn't use any trigonometry at all :)

That would suggest that I first need to know pi (and I'm guessing that isn't 3.1415). In this case, is pi the intersection of the point on the surface?

Lets go to a visual aid:
http://www.eonclash.com/physics/p2s_calc.jpg

Given your above code I think that the following mapping is appropriate:
N - Normal of the intersection point of [V-1]->V to A->B
A.RayDirection - V - [V-1]
cEpsilon - Proper Scaled Epsilon (please tell me you arn't using static 0.0000001 :) in a ray tracer)

My response (using dts as Delta Time Step difference) [nV-dts]->nV would then be equal to reflray.Origin->R correct?

paul_nicholls

30-07-2009, 08:36 PM

sorry, pi is point of intersection of the incident ray. I got the calculations from this page about raytracing: