Skip to content

Golden Ratio Obstacle Avoidance

Phani Srikar edited this page Jul 10, 2020 · 14 revisions

What is Golden Ratio?

In mathematics, two quantities are said to be in golden ratio if the ratio of sum of largest and smallest number to largest number is equal to ratio of largest to smallest number. The figure below illustrates the geometric relationship. Expressed algebraically, for quantities a and b with a > b > 0,

  • In design, layouts are the perfect place to start applying the Ratio. Two-column layouts are extremely common. But weighing the columns differently adds a dynamic flow to any publications. Webpages, in particular, use the sidebar concept to apply a dynamic, weighted feel that works naturally.

  • But what should the dimensions be? The units of measurement do not matter. The larger edge of the larger rectangle should be 1.618 times the length of the edge of the smaller rectangle.

  • For example, most web layouts are 960-pixels wide. When divided by 1.618, you get 594 pixels. This will be the height of the project layout. To divide it into columns, you do the same again. The large box, whether placed on the right or left of the layout grid, will also be 594 pixels wide. The smaller sidebar will be 366 pixels wide by 594 pixels tall.

  • You can continue the pattern as far as you like. The smaller rectangle can be divided down similarly as far as your design will allow. If you want to place additional elements inside the two-column framework that you created above, use ever smaller and diminishing rectangles to place them. You can also place elements using the spiral based on those rectangles. Details of your design will become denser as the viewer’s eyes spiral towards the apex. This is an excellent way to balance white space in a design and maintain a pleasing balance.

  • Another excellent example of applying the Ratio in design comes in logo design. Many iconic logos can be distilled down to the ratio. By using 1:1.618 to all manner of shapes, cutouts, fills, and patterns, the symmetry of design can really come together. Search online, and you can find some excellent analyses of how some of the most iconic corporate brands benefit from the use of the Ratio in their designs. These are simple examples, but it’s essential to realize that the Ratio can be repeated in a work several times over. If you divide your canvas into rectangles starting from the left, you can do it again from the right. Then, you have the same proportions centering elements, much like the Rule of Thirds in photography.

  • To go one step further, golden rectangles can be drawn over the frame both vertically and horizontally. Many experts interpret Leonardo’s The Last Supper in this manner, with rectangles drawn from all edges. The Ratio can even be used to figure out what size font you should use. If you have trouble figuring out the typography for a project, take the size of the body font and multiply by 1.618. So, if the body font is 10 points, then the headers should be approximate 16 points. Page titles above that? Try 26 points or so. The rule can be applied the other way, too, if you want to set your title or heading size and figure out the body text size.Once you see the magic of the proportions, the number of ways that they can be applied to your designs are limitless.

What is Golden Angle?

In geometry, the golden angle is the smaller of the two angles created by sectioning the circumference of a circle according to the golden ratio; that is, into two arcs such that the ratio of the length of the smaller arc to the length of the larger arc is the same as the ratio of the length of the larger arc to the full circumference of the circle.

  • The Golden Angle happens when you break up a circle so that the ratio of the big arc to the little arc is the Golden Ratio. It’s like taking the line definition of the Golden Ratio and wrapping it into a circle – green is to red as red is to blue. The resulting angle (marked in the figure) is the Golden Angle, and if you do the math you find that the angle is about equal to 137.5 degrees.
  • We can use this logic to draw some interesting points on a disk and space, explore the Google Colab notebook on Golden Spiral Open in Colab to get a deeper understanding about the algorithm implementation and the formation of patterns.

  • Now we use the points generated by this algorithm to draw raycasts (to create a sphere of vision with a viewing solid angle) around out object upto a certain height to check for any kind of collision detection and choose the best free direction to move forward, once we couple this type of avoidance with separation, alignment, cohesion we get a really good flock behaviour.

Do look at the References section for the learning resources that helped me.

So how do we use all this to avoid obstacles?

What are Boids ?

Boids is an artificial life program, developed by Craig Reynolds in 1986, which simulates the flocking behaviour of birds. His paper on this topic was published in 1987 in the proceedings of the ACM SIGGRAPH conference. The name "boid" corresponds to a shortened version of "bird-oid object", which refers to a bird-like object. Incidentally, "boid" is also a New York Metropolitan dialect pronunciation for "bird".

Rules applied in simple Boids :

  • Separation

  • Alignment

  • Cohesion

As with most artificial life simulations, Boids is an example of emergent behavior; that is, the complexity of Boids arises from the interaction of individual agents (the boids, in this case) adhering to a set of simple rules. The rules applied in the simplest Boids world are as follows:

Separation: steer to avoid crowding local flockmates.

Alignment: steer towards the average heading of local flockmates.

Cohesion: steer to move towards the average position (center of mass) of local flockmates.

So How do we apply this ?

Well, first thing we need are a bunch of rays in a spherical shape around the player, but how do we know what are those points to draw those rays? That's where we use this golden ratio sphere to generate those points and use those points to draw the rays, and then use those rays for collision detection and choose the best direction to move along with Boid movement rules such as alignment, cohesion and separation.