- Rejection method. You try a location with a known size and known orientation, and if it does not fit right there, you reject the attempt and try another random configuration. As the area gets more full, you can end up taking a long time to find new locations. This approach is not smart about placements, and figuring out whether to give up yet can be tricky, but it can make some guarantees about sizes
- Fitting method. You try a location with a known size and known orientation, and if it happens to work, then you use it. But if it does not work, then you look at a particular point such as the center point of the line, and see if it is occupied or not; if it is occupied, you go back to try another location. But if the center point is not occupied, then you try other orientations; or you figure out how long of a line you could put in at that location and "shrink" appropriately. You figure out what will fit at the location, and you go with that. This approach can be much smarter about placements, taking less time to execute, but it does is unlikely to fit any particular distribution of sizes. In particular, the number of small lines you end up with, will be much greater than the number of long lines.
- Dynamics method. You toss a bunch of objects into the area one at a time, and each time it would not normally fit, treat it as pushing on existing objects -- which in turn push on other objects, and the wall, and things push back, until eventually enough has moved relative to each other that everything fits and has stopped moving. There are related methods based upon "shaking" the container until everything fits. This approach can make some guarantees about sizes, but the motion calculations can take a bit of time.
How do I plot random lines, condition : lines cannot intersect each other? Lines can not intersect the boundary box?
1 view (last 30 days)
Show older comments
How do I plot random lines in a boundary box?
condition : lines cannot intersect each other?
Lines can not intersect the boundary box?
3 Comments
Walter Roberson
on 22 Apr 2020
X1 = [x1o(i) x1i(i)];
Y1 = [y1o(i) y1i(i)];
x1o and x1i and y1o and y1i are not defined, and not documented as to what they might be.
I do not see any calls to random routines so I suspect you need to put in some calls to generate random lines.
Your code appears to be looping until it finds the first intersection and then stopping immediately ?
Answers (0)
See Also
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!