Top 5 Recent Articles
ARTICLES CATEGORIES
- Algorithms (22)
- All (399)
- Biography (1)
- Blog (44)
- Business Requirements (1)
- Commentary (1)
- Conversion (2)
- Customers (2)
- Data Models (1)
- Education (2)
- GeoRaptor (13)
- GPS (1)
- Image Processing (2)
- Import Export (8)
- Licensing (2)
- LiDAR (1)
- Linear Referencing (4)
- Manifold GIS (3)
- Mapping (1)
- MySQL Spatial (7)
- Networking and Routing (including Optimization) (5)
- Open Source (18)
- Oracle Spatial and Locator (194)
- Partitioning (1)
- PostGIS (36)
- Projections (1)
- Published Articles (1)
- qGIS (1)
- Recommendations (1)
- Services (1)
- Software Change Log (1)
- Source Code (37)
- Space Curves (9)
- Spatial Database Functions (109)
- Spatial DB comparison (1)
- Spatial XML Processing (11)
- SQL Server Spatial (92)
- Standards (3)
- Stored Procedure (17)
- Tessellation or Gridding (10)
- Tools (2)
- Topological Relationships (1)
- Training (2)
- Triangulation (2)
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 * separation and radius * @version : 1.0 * @usage : FUNCTION OptimalCircleSegments( @dRadius Float, * @dArcToChordSeparation Float) * RETURNS INTEGER * eg select cogo.OptimalCircleSegments(10,0.01) as segments; * @param : @dRadius : Radius of Circle * @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. */ Create Function [cogo].[OptimalCircleSegments](@p_dRadius Float, @p_dArcToChordSeparation Float) Returns Integer As Begin DECLARE @dAngleRad Float, @dCentreToChordMidPoint Float; BEGIN IF ( @p_dRadius IS NULL OR @p_dArcToChordSeparation IS NULL ) RETURN NULL; SET @dCentreToChordMidPoint = @p_dRadius - @p_dArcToChordSeparation; SET @dAngleRad = 2 * aCos(@dCentreToChordMidPoint/==@==p_dRadius); Return CEILING( (2 * PI() ) / @dAngleRad ); END; END GO
Here is an example of how to use the function.
select cogo.OptimalCircleSegments(10,0.01) as segments;
I hope this is useful to someone.
Documentation
- MySQL Spatial General Functions
- Oracle LRS Objects
- Oracle Spatial Exporter (Java + pl/SQL)
- Oracle Spatial Object Functions
- Oracle Spatial Object Functions (Multi Page)
- PostGIS pl/pgSQL Functions
- SC4O Oracle Java Topology Suite (Java + pl/SQL)
- SQL Server Spatial General TSQL Functions
- SQL Server Spatial LRS TSQL Functions