How do I draw a rounded rectangle?

Hi All. I want to draw a closed rounded rectangular road. It is regrettable that I’m not good at math. I don’t know how to draw the filleted corner of the other three angles.
pg: Babylon.js Playground
(The entire graph is parallel to the XZ plane)

Here is an PG I did quickly:
the idea is to have a current position and add a small step each iteration with an angle. The code is pretty small. let me know if you don’t understand something.


It’s really elegant!

1 Like