• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# particle system problems

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1Gecko  Members

Posted 03 March 2000 - 06:37 AM

i''m working on a particle system right now and am having some trouble with the latest part. i''m trying to make the particles always have acceleration towards the cursor position. i''m sure you''ve all seen those little java apps on the net where the particles follow your cursor around and kind of orbit it. i''d appreciate some help
_________________Gecko___ Gecko Design

### #2Novalis  Members

Posted 03 March 2000 - 07:07 AM

Sure thing, It''s easy...

void GetAcceleration(whatever *particle, whatever *mouse, Vector *accel)
{
/* Get the vector from the particle to the mouse. */
VectorSubtract(mouse->origin, particle->origin, accel);

/* Normalize the above vector (ie make it a 1 unit long vector). */
VectorNormalize(accel);

/* Now scale the vector to your rate of acceleration. */
VectorScale(accel, 10.0);
}

### #3Gecko  Members

Posted 03 March 2000 - 07:42 AM

Ah, thanks!
where can i find implementation of those functions?

_________________Gecko___
Gecko Design

### #4Spellbound  Members

Posted 03 March 2000 - 09:16 AM

You have to make them yourself.

Or you can use D3DX

### #5Gecko  Members

Posted 03 March 2000 - 12:02 PM

yes i know i have to make them myself. my question was HOW do i make them. actually the only one i need help with is VectorNormalize.

_________________Gecko___
Gecko Design

### #6chippydip  Members

Posted 03 March 2000 - 12:23 PM

To normalize a vector, all you have to do is divide by its length. For example, if your vector

v = (x, y)

then the length is just

/v/ = sqrt(x^2 + y^2)

thus the normalized vector will be:

(x, y)//v/ = (x//v/, y//v/)

Simple... hope that helps

(There''s some room for optimization in the math... especially in the sqrt() function which could probably just be aproximated with exceptable result.)

### #7chippydip  Members

Posted 03 March 2000 - 12:25 PM

Woah! most of those slashes are supposed to be vertical bars ''/'' I wonder why that happend... Oh, well... they are supposed to be the absolute value (ie, the normalized value) of the v vector.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.