Tuesday, July 5, 2022
HomeGame DevelopmentGenerate random line path with no intersection

Generate random line path with no intersection


The thought is to generate a path with a sure distance d.
At present the era pseudo code is as follows:

traces: Checklist of line

traces[0]: line beginning at (x:0, y:0) and ending at (x:0, y:1)
for i: 1 to m:
    random_angle: randomly generate angle between -90 and 90 degress.
    traces[i]: new line beginning on the finish of traces[i-1] forming and angle = random_angle 
    between traces[i-1] and and features[i]

The final concept is illustrated within the under:

enter image description here

However the issue is that when m is sufficiently big the traces create a loop and find yourself intersecting one another.

enter image description here

Any resolution to this ?

1- Been looking for a very good math library that detects the intersection between 2 traces,
then test for every new line if it intersects the others already created, however no library was discovered

2- Any one other algorithm that may generate a random line path ?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments