• Advertisement

Archived

This topic is now archived and is closed to further replies.

particle system problems

This topic is 6529 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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);
}

Answer your question? I can provide more details if you want... I''m not sure how much help you need

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement