Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   how to write a function (http://www.go4expert.com/forums/write-function-t5993/)

 allwiyn 23Aug2007 08:48

how to write a function

hi,
How to write a function that checks if the circle passes through four given points.

plz give me the logic or concept for making this function.

 seeguna 23Aug2007 12:05

Re: how to write a function

It is better to go thru some circle clipping algorithms for better implementation

 oleber 23Aug2007 12:42

Re: how to write a function

Calculate the center of the circle (probably you have it :p).

And calculate the distance of this points to the center. :cool: Mathematics

 listendinesh 24Aug2007 16:23

Re: how to write a function

If you have radius and center cordinates then you can use the standred equation of circle.

((X- H)*(X -H)) + ((Y -K)*(Y - K)) = R*R

H -> center x cordinate
K -> center y cordinate

X -> x cordinate of given point
Y -> y cordinate of given point

Make a function which take two arguments ( given point x and y cordinate) and return a bool flag ( true if circle passes through given point otherwise false).
In function
calculate X -H and get its sqrt
(Given point X - Center Point X)
calculate Y -K and get its sqrt
```struct point { int x, int y };```