degrees to x and y
Hello, I'm trying to make a particle editor and I have a problem trying to implement the "spread" of particles. It's hard for me to explain what I mean by this so I will show you [smile].
Say I want a spread of 90 degrees:
Particles could be anywhere between the two upper 45 degree lines.
Here is an example from another particle editor:
Quote:
What's the question?
spread = 90.0f;
dirextion.x = ?
direction.y = ?
In other words if I have a spread of 90 degrees how do I make sure particles stay between those two upper 45 degree lines in the first picture?
spread=pi/2; //90 degreesangle=random_scalar()*spread;direction.x=sin(angle);direction.y=cos(angle);
random_scalar just being a random function spitting out a value in the range of 0-1. A cheap example of that being:
float random_scalar(){ return (float)rand()/RAND_MAX;}
Quote:
random_scalar just being a random function spitting out a value in the range of 0-1. A cheap example of that being:
Wouldn't that only give me answers in the 1st quadrant?
Quote:Original post by subfloodQuote:
random_scalar just being a random function spitting out a value in the range of 0-1. A cheap example of that being:
Wouldn't that only give me answers in the 1st quadrant?
Borrowing random_scalar() from ProPuke:
angle = min_angle + random_scalar() * ( max_angle - min_angle ); x = cos( angle ); y = sin( angle );
or... angle = min_angle + random_scalar() * spread; x = cos( angle ); y = sin( angle );
or... angle = center_angle + ( random_scalar() - 0.5f ) * spread; x = cos( angle ); y = sin( angle );
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement