Attracting forces

Started by
13 comments, last by someusername 18 years, 1 month ago
Was hoping some one could clear this up for me im trying figure how i could displace a particle stream by using 3d points that would attract or repel the particles given there distance from the center. At the moment ive only got a gravity force which is just a constant -9.8 in the y im not entirely sure how you'd pull objects towards a single point... thx alot for any help fishy
Advertisement
Simple, the direction of the force is the displacement vector from the source of the force to the particle being acted on, and has magnitude (for an inverse square force) proportional to 1/r^2 where r is the distance between the two.

So therefore, the acceleration of a particle in terms of the displacement vector v and a constant c is:

cv/(||v||^3)
Im sorry you lost me is there a more err easier way of putting it.

How do you obtain the displacement vector ? Not totally sure i understand what c is.

My maths isnt exactly the best id love to know of a good book if anyone knows of one that explains the very basics of physics but doesnt forget to explain the jargon.
displacment vector 'v' is the vector between the gravity source, and the object you want to move

'c' is an adjustable strength for the gravity

if you dont know what a vector is, wait a while for an experienced member to convert you to the 'church of vectors'...
hmm, the solution suggested by the posters above will effectively put the particles in orbit around the points you will define.
Is this what you wanted?... Or being able to define a "stream curve" for all particles to follow, and be able to influence their trajectory with reference points you will assign in 3d space?

If you go for the latter, you'll need b-splines instead
Quote:Original post by someusername
hmm, the solution suggested by the posters above will effectively put the particles in orbit around the points you will define.
Is this what you wanted?... Or being able to define a "stream curve" for all particles to follow, and be able to influence their trajectory with reference points you will assign in 3d space?

If you go for the latter, you'll need b-splines instead


No you don't. I assume this guy has some particle system where each particle has an acceleration added to its velocity every time interval - since he has a gravity acceleration which simply adds -9.8 to the velocity in the y-direction.

Deflecting a particle stream towards a point works exactly in that same fashion, except that the acceleration is an arbitrary constant c and not just -9.8. Plus, it's in the direction of the displacement vector, not just the y-direction. What makes the cool deflection pattern is that the force direction/magnitude changes as the particles get closer to the source of the force.

BTW, finding the displacement vector is easy. Just draw an arrow form one point to another. The vector's x-component is the length of the arrow in the x-direction and the y-component is the length in the y-direction. I gotta dash so someone else will have to explain vectors more...
We're talking about different things.

You describe how one can simulate particles being attracted/repelled by "point-masses" positioned in space, using forces similar to those of the law of global attraction. (inv.square law)
What you speak of, is a physical simulation, whose final state may -in fact- become very difficult to control. (unless -of course- this is intended)

I was talking about explicitly moving particles on a known -predefined- trajectory, (the spline) which you can influence with as many control points as you want, just like with nurbs or something.
You know where all particles will start from, where they'll end up, how long that will take, which way they'll go, what their velocity/acceleration will be anytime...

Explicitly moving particles on a curve, and letting them move under the affect of gravitational acceleration is not the same thing. That's why to model something like what I was talking about, I suggested that one would probably need b-splines.
Yeah he was right id like to have orbit points that i could shot around that would effect the particles slightly based on there distance from the center. The bspline thing would be really cool to have but at the moment i was just hoping to keep it very simple then eventually move onto something like bspline.

Quote:
So therefore, the acceleration of a particle in terms of the displacement vector v and a constant c is:

cv/(||v||^3)

With this maths notation its just simply,
c * v / ( len(v) to the power of 3 ) = new acceleration

Thx a tonne for the help so far hoping someone can clear a few things up just so i understand it better.

I normally calc velocity by doing,

Accel = Force/mass;

Vel = Vel + (Accel * dt);

So lets say i have my point C = { 0 2 0 } so my displacement vector would just be P = particle pos Dv = P - C.

But what i dont understand is how do i apply this new acceleration on top of whats already effecting the particles ? Would you simple just add it on top on the current acceleration ?

thx again
fishy
The displacement vector v from point P1(x1,y1,z1) to P2(x2,y2,z2), is simply the coordinates of point P2 measured from P1 (as if P1 was the origin)
This gets down to: v = P2-P1 = (x2,y2,z2)-(x1,y1,z1) = (x2-x1, y2-y1, z2-z1)

You can do something like this:
1. Loop for all particles P(i),2.   TotalForce = 0;3.   Loop for all attractors A(j)4.     Calculate Displacement vector v from particle to attractor. v = A(j).Pos - P(i).Pos5.     TotalForce += (c/|v|2)*v6.   End loop (3)7.   P(i).Acceleration = TotalForce/P(i).Mass8.   P(i).Velocity += P(i).Acceleration*dt  9.   P(i).Pos += P(i).Velocity*dt10.End loop (1)


The magnitude of a vector is the square root of the sum of its squared components:
|v|=sqrt( x2+y2+z2 )
Since you need the squared magnitude above, you can lose the sqrt(), and implement this as the dot product of v with itsself.
Cheers m8 i get it now :)

Ill give it ago later and tell ya how i get on.

This topic is closed to new replies.

Advertisement