Circular Arcs in OpenSCAD easily

Trying to find an easy way to make arcs and rings in OpenSCAD without subtracting shapes but thru math. You can choose the origin of the arc, radius of the arc, arc angle, arc thickness, and where on the radius the arc starts. If you make a 360 degree arc it becomes a ring. 2D

** Updated to include code to make the arc a tube or smooth cylinder.. 3D

** Updated cylinder code, to rotate cylinder properly..

** Updated 11Sep2024 Code draws arc more efficiently and makes a proper curve V2.