How to define random points above and below a define line within a specific range

20 views (last 30 days)
  1. Suppose line equation is given by y=mx+c and i have a random set of values of x
  2. Then we can get corresponding values of y
  3. Now with the line defined I would like to define random points above and below the line and within a specific range
  3 Comments
Santosh Prakash
Santosh Prakash on 16 Apr 2017
Edited: Santosh Prakash on 16 Apr 2017
I would like to have the points uniformly distributed about the line. The line defines what angle or orientation I need the points. More on the application I intend to use. I need to model blood vessel with points representing the components randomly placed within the vessel. And the orientation of the blood vessel can be variable. The line is to be used as the center of the vessel with particles around it. Range of points or particles is defined by the radius of vessel.
Santosh Prakash
Santosh Prakash on 17 Apr 2017
Attached required rough design.
Line is the dashed line. I require particles uniformly distributed about the line(represented by the rectangular region) Then I need to check the particles if they are within the vessel(represented with the cylinder) and define a velocity model based on the distance from the line.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 16 Apr 2017
Edited: Image Analyst on 16 Apr 2017
Do you just want to add uniformly distributed noise, like
y = y + amplitude * rand(1, length(y));
  7 Comments
Image Analyst
Image Analyst on 17 Apr 2017
I think the code, as-is, should do the job. I don't think tilting the random locations would lead to a substantially different random arrangement.

Sign in to comment.

More Answers (1)

Roger Stafford
Roger Stafford on 17 Apr 2017
Let w be the allowed perpendicular distance of random points on either side of the line segment. Let x1 be the x-coordinate of left end of segment and d be the segment’s length. Let N be the desired number of random points.
a = atan(m);
x = d*cos(a)*rand(N,1)+x1;
y = m*x+c;
h = 2*w*rand(N,1)-w;
x = x - h*sin(a);
y = y + h*cos(a);
X = [x1,x1+d*cos(a)];
Y = m*X+c;
plot(x,y,'y.',X,Y,'r-',X,Y,'r*')
axis equal

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!