Note that there are some explanatory texts on larger screens.

plurals
  1. POFractally generated lines with pre-specified endpoints
    text
    copied!<p>Here is my problem:</p> <p>I have two random points (x,y) and (x2, y2). I would like to great a 'random-step' or fractal line between the two. I have set up a situation wherein the step distance and direction are randomly generated based on a probability matrix. However, leaving it solely to the direction of this matrix, the line will have a random endpoint which is impossible to pre-determine. I have therefore attempted to set up bounds for my line where--if a point falls--the location is adjusted accordingly. These bounds are not working. </p> <p>Ideally, my boundaries would be a circle created with each random point at opposite ends of the area. I have tried the following.</p> <ol> <li><p>I have set up a loop which will iterate through each x-point of the line using a variable <strong>i</strong> which starts with the lesser of x and x2 and moves towards the greater.</p></li> <li><p>I have set up a variable <strong>j</strong> to which the random step will be added and initialised it to the equivalent y-value for the lesser x-value (if x1 is greater set to y1 else set to x).</p></li> <li><p>I have set up a variable which contains the slope of the theoretical straight line between x,y and x1,y1.</p></li> <li><p>I have set up a probability matrix which takes a variable <strong>mod</strong> and sets it to a value between 8 and -8.</p></li> <li><p>I have set up checks to disallow the formation of the line outside of the boundaries of the given plane.</p></li> <li><p>I have set up a check to determine if the variable <strong>i</strong> is one less than the greater of x and x2. If so, variable <strong>j</strong> is set to that x-value's y-value;</p></li> </ol> <p>It is at this point that I fail to find the appropriate algorithm to set up the final check. Here is what I would like the algorithm to do:</p> <p>A. I would like it to be able to, given a random x-value between x and x1, determine if the current variable <strong>j</strong> added to the current variable <strong>mod</strong> is outside of the circle generated by the two aforementioned points (see the second paragraph). If it is not, add mod to variable <strong>j</strong> and increment the loop.</p> <p>B. If this point would fall outside the bounds, I would like the step direction to be reversed (e.g. -6 to 6 and 2 to -2) and the same check to be made again.</p> <p>C. If adding in either direction would put it out of bounds (which will most likely happen near the far end of the circle where the boundaries constrict the most), I would like to be able to run through a loop which checks each value and its inverse beginning at 0 and moving to consecutively larger values until a workable value is determined.</p> <p>I hope you experience mathematicians and programmers out there see this as a surmountable challenge. It has stumped me for three weeks and I have run out of ideas.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload