Calculate the heading of a point from a previous point randomly in a range

50 Views Asked by At

Let us consider we have two points $A$ and $B$. Point $A$ has an attribute called "heading" which is in degrees and between 0 and 360 degrees. Heading of point $B$ needs to be calculated randomly based on that of point $A$. This randomness should be between $-22.5$ to $22.5$ degrees of heading of point A (this is the maneuverability of a shipping vessel). How this heading of point $B$ is calculated to ensure that a sequence of this points where each point's heading depends on the last one is getting farther away than the first point?

This means that if we have a sequence of points $\{A, B, C, D\}$ and the heading of $A$ is known, the heading of $B$ is randomly chosen based on the criteria mentioned above from those of $A$ and the heading of $C$ is chosen from $B$ and so on. And we must ensure that we are getting farther away from $A$ as we chose these random headings.

I ask this question because I am facing this problem while implementing a particle system with a movement model.

1

There are 1 best solutions below

3
On

Suppose you have arrived at point $Y$ from point $X$ after some number of steps. Draw the line $L$ perpendicular to $AY$ at $Y$. Since the trip from $X$ took you further from $A$, you will see $A$ and $X$ on the same side of $L$. At $Y$ draw the cone of possible new headings. If that cone is entirely on the far side of $L$ from $A$, choose the new heading at random from it. If $L$ cuts the cone then choose at random from the subset of the cone on the far side of $L$. You will need some angle calculations from known data.

I might get around to drawing a picture to insert here.