Random Point on a line

Started by
3 comments, last by VisualB4BigD 21 years, 10 months ago
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)
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).
Where does randomness play a part in this?

Horny Farmer (Jolly Rancher)
n is a random number in the formula VolkerG gave you.
Problem Solved, thanx again for all your help guys.

Horny Farmer (Jolly Rancher)

This topic is closed to new replies.

Advertisement