COGO: Compute number of vertices required to stroke circle or circular arc

In working with circles or arc segments one needs to be able to do more than just calculate chordlengths, arclengths or arc2chord separations.

For example, in order to be able to convert circles and arcs to vertex-stroked polygons and vice versa one needs to be able to compute the number of vertices to place between the points that subtend an arc on the circumference. This is what this function does.

Note that I have a schema call cogo in which I create functions like this. You can use anything you like.

``` /* ----------------------------------------------------------------------------------------
* @function   : OptimalCircleSegments
* @precis     : Returns the optimal integer number of circle segments for given arc-to-chord
* @version    : 1.0
* @usage      : FUNCTION OptimalCircleSegments( @dRadius Float,
*                                               @dArcToChordSeparation Float)
*                        RETURNS INTEGER
*               eg select cogo.OptimalCircleSegments(10,0.01) as segments;
* @paramtype  : @dRadius                 : Float
* @param      : @dArcToChordSeparation   : Distance between the midpoint of the Arc and the Chord in metres
* @paramtype  : @dArcToChordSeparation   : Float
* @return     : OptimalCircleSegments    : the optimal number of segments
* @rtnType    : OptimalCircleSegments    : Integer
* @note       : Does not throw exceptions
* @note       : Assumes planar projection eg UTM.
* @history    : Simon Greener - Feb 2005 - Original coding.
*/
@p_dArcToChordSeparation Float)
Returns Integer
As
Begin
DECLARE
@dCentreToChordMidPoint Float;
BEGIN
IF ( @p_dRadius IS NULL OR
@p_dArcToChordSeparation IS NULL )
RETURN NULL;

SET @dCentreToChordMidPoint = @p_dRadius - @p_dArcToChordSeparation;
``` select cogo.OptimalCircleSegments(10,0.01) as segments;