Skip to main content
gamedev.net
🔒 Locked

Random Point on a line

Started by VisualB4BigD Jun 2, 2002 at 4:54 AM 3 replies 400+ views
Original Post
VisualB4BigD
VisualB4BigD
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)
VolkerG
VolkerG
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).
VisualB4BigD
VisualB4BigD
Where does randomness play a part in this?

Horny Farmer (Jolly Rancher)
VisualB4BigD
VisualB4BigD
Problem Solved, thanx again for all your help guys.

Horny Farmer (Jolly Rancher)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.