Good method to find same denominator for 3 different rations

Can this ‘rat()’-function find all 3 ratios, but with same denominator?
I had some solution to this as in below code, but not sure if that is how to solve this issue:
plot_polygon.m (909 Bytes)

My system

  • OS: MXLinux21.1
  • Octave version: 6.2.0

I was going to ask about taking the LCM of the denominators but I see you’re already doing that. There isn’t a better method for that.

From your code it looks like you’re trying to snap certain points to the nearest 0.01 in the grid. It would be easier to do round (x * 100) / 100 instead of going through rat and lcm. You’re not using the rational numbers except to snap to grid.