Jump to content
  • Advertisement

Archived

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

VisualB4BigD

Random Point on a line

This topic is 5986 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 want to to pick a random X and Y coord on a line genererated with only the info given below. Here are the variables I have MidPoint of the line (X,Y) Angle of the line from the mid point (Radians) Length of the entire line I want a math algo that will pick a random point on this line with only the info given. Can someone help me? If your wondering it''s for a line emitter in my particle engine. Horny Farmer (Jolly Rancher)

Share this post


Link to post
Share on other sites
Advertisement
Well, generate a random number in the range [-Length/2, Length/2]. Use this number as distance from your center point:
Point = c + n * x0
where c is the center point, n is the number and x0 is the unity direction vector of your line (can be calculated from the angle).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!