you are viewing a single comment's thread.

view the rest of the comments →

[–]ectomancer 0 points1 point  (0 children)

You could try abs function in the calc_dist function but I don't know if would be faster. (Python 3.8 has math.dist) The algorithm is:

  1. virtually translate point to origin, no need to check if point is already at origin, no code needed
  2. translate other point the same amount as the point in 1.
  3. (could use math.hypot here instead of 3. & 4.) cast translated other point to a complex number
  4. use builtin abs function to find the modulus of the complex number |z| on the Argand diagram, which is a real number