How to draw a random point on a specific line within a specific boundary.

1 Ansicht (letzte 30 Tage)
Let the
XY_BOUNDARY = [0,70,0,50};
position = [XY_BOUNDARY(2) - XY_BOUNDARY(1); XY_BOUNDARY(4) - XY_BOUNDARY(3)] .* rand(2,1) ...
+ [XY_BOUNDARY(1);XY_BOUNDARY(3)];
In the above code i get a random number within the specified boundary. Now i want the random point position in a specified boundary as well as on the line connecting two points (x1,y1), and (x2,y2, which are also present within the defined boundary...Please tell me how to do this
  1 Kommentar
Melanie Schmocker
Melanie Schmocker am 3 Aug. 2016
Bearbeitet: Melanie Schmocker am 3 Aug. 2016
Are (x1,y1) and (x2,y2) already stored in your code and you want to find a point on the line between them? Or do you want to generate them randomly from within the boundary and then select a random point on the line between them?
If they're already stored in your code, are they guaranteed to be within the boundary?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by