Python Cookbook
by
Alex Martelli, David Ascher, David M. Beazley, Brian K. Jones
Description: Python Cookbook provides a collection of coding recipes for Python programmers, covering practical solutions for various tasks and applications. The book includes updated content relevant to Python 2.4
We may earn a commission from purchases made through links on this page.
Lets assume we need 50 degrees angle and we have piece of paper with 100x100 cells. We can construct rightangled triangle and seek for closest legs proportion which gives desired angle between one of legs and hypotenuse.
Desired proportion must be rational number closest to tan(50 deg). We can find such rational number by seeking Farey sequence limited with denominator less than 100. So, for this case triangle with 87 and 73 cell legs will give us 50.000644597558434 degrees angle. Looks pretty good result to me.
I think, in case with two non-aligned rays we can reduce it to first case by building two triangles and constructing angle between hypotenuses.
Useful links:
https://en.wikipedia.org/wiki/Farey_sequence
https://www.oreilly.com/library/view/python-cookbook/0596001... - python implementation of search in Farey sequence.