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: Finding centre and radius of a curve defined by three points: FindCircle function
Recently I had need to convert a PL/SQL Oracle Spatial function I created years ago called FindCircle to SQL Server 2008 for use in another project. That function was original work already released to the public domain as part of my free COGO package for Oracle. Here is that function for SQL Server.
Note that I have a schema call cogo in which I create functions like this. You can use anything you like.
/** ---------------------------------------------------------------------------------------- * @function : FindCircle * @precis : Function that determines if three points form a circle. If so a table containing * centre and radius is returned. If not, a null table is returned. * @version : 1.0 * @usage : Function FindCircle(@p_X1 float, @p_Y1 float, * @p_X2 float, @p_Y2 float, * @p_X3 float, @p_Y3 float ) * Returns @circle table ([cx] float, * [cy] float, * [radius] float ) * eg select c.cx, c.cy, c.radius * from [FindCircle](0.0,0.0,10.0,0.0,10.0,10.0) c; * @param : p_X1/p_Y1 : First point in curve * @param : p_X2/p_Y2 : Second point in curve * @param : p_X3/p_Y3 : Third point in curve * @return : cx/cy/radius : Centre X, Y and radius of found circle or NULL if three points do not form a circle. * @history : Simon Greener - May 2011 - Original coding. * @copyright : Licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License. (http://creativecommons.org/licenses/by-sa/2.5/au/) **/ CREATE FUNCTION cogo.FindCircle(@p_X1 FLOAT, @p_Y1 FLOAT, @p_X2 FLOAT, @p_Y2 FLOAT, @p_X3 FLOAT, @p_Y3 FLOAT ) RETURNS @circle TABLE ( [cx] FLOAT, [cy] FLOAT, [radius] FLOAT ) etc
The function can be used as follows:
SELECT c.cx, c.cy, c.radius FROM cogo.FindCircle(0.0,0.0,10.0,0.0,10.0,10.0) c;
|_. cx|_. cy|_. radius| |5|5|7.07106781186548| If anyone would like the source code for this function, please contact me directly. Simon
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