GEOarcFrom3Points

Top  Previous  Next

Calculation of radius and centre of a circle.

This function calculates from 3 points which lie on a circle, the radius and the centre of the circle. If (x1, y1) and (x3, y3) are identical, the smallest full circle from (x1, y1) about (x2, y2) after (x1, y1) is calculated.

Parametre

x1 (const STANDS IN) [IN]

y1 (const STANDS IN) [IN]

x2 (const STANDS IN) [IN]

y2 (const STANDS IN) [IN]

x3 (const STANDS IN) [IN]

y3 (const STANDS IN) [IN]

3 points on the circle. The situation of starting point, centre and terminator point determine which direction of the circle is calculated.

r (STANDS IN *) [IN / OUT]

The radius of the circle r must be a valid pointer on a variable of the type STANDS IN who is filled by the procedure if the calculation is possible, i.e. if three points do not lie on a line. If the returned radius is a negative value, there runs the circle from (x1, y1) about (x2, y2) after (x3, y3) in mathematically negative direction.

xc (STANDS IN *) [IN / OUT]

yc (STANDS IN *) [IN / OUT]

Calculated centre of the circle. Both variables must be valid pointers. The variables are filled by the procedure with the co-ordinates of the centre of a circle if three points (x1, y1), (x2, y2) and (x3, y3) do not lie on a line.

Result

INT OUT

0 OK: successful calculation

-1 mistakes: two points are identical.

Declaration

#include "basic.h"

 

int DLLENTRY GEOarcFrom3Points (

const STANDS IN x1,

const STANDS IN y1,

const STANDS IN x2,

const STANDS IN y2,

const STANDS IN x3,

const STANDS IN y3,

STAND-IN * r,

STAND-IN * xc,

STAND-IN * yc

);

Example

status = GEOarcFrom3Points (100.0, 50.0, 50.0, 100.0, 100.0, 150.0, &r, &xc, &yc)

The variable status receives the value 0, i.e. the calculation could be carried out. The centre lies with (100/100) the radius has the value 50.