• Advertisement

Archived

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

Random Point on a line

This topic is 5710 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