Circumcicle of a triangle

Blitz3D Forums/Blitz3D Beginners Area/Circumcicle of a triangle

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Thanks!

I will look for the examples.

In the meantime I found an C-Code and convert it to BB:

Global xc#,yc#,r# ;Kreismittelunktkoordinaten und-Radius

Const EPSILON#=0.000001

Function CircumCircle(xp#,yp#,x1#,y1#,x2#,y2#,x3#,y3#)
Local m1#,m2#,mx1#,mx2#,my1#,my2#
Local dx#,dy#,rsqr#,drsqr#

If (Abs(y1-y2)<EPSILON And Abs(y2-y3)<EPSILON) Then
Return False
ElseIf(Abs(y2-y1)<EPSILON)Then
m2=-(x3-x2)/(y3-y2)
mx2=(x2+x3)/2.0
my2=(y2+y3)/2.0
xc=(x2+x1)/2.0
yc=m2*(xc-mx2)+my2
ElseIf Abs(y3-y2)<EPSILON Then
m1=-(x2-x1)/(y2-y1)
mx1=(x1+x2)/2.0
my1=(y1+y2)/2.0
xc=(x3+x2)/2.0
yc=m1*(xc-mx1)+my1
Else
m1=-(x2-x1)/(y2-y1)
m2=-(x3-x2)/(y3-y2)
mx1=(x1+x2)/2.0
mx2=(x2+x3)/2.0
my1=(y1+y2)/2.0
my2=(y2+y3)/2.0
xc=(m1*mx1-m2*mx2+my2-my1)/(m1-m2)
yc=m1*(xc-mx1)+my1
EndIf
dx=x2-xc
dy=y2-yc
rsqr=dx*dx+dy*dy
r=Sqr(rsqr)
dx=xp-xc
dy=yp-yc
drsqr=dx*dx+dy*dy
Return (drsqr<=rsqr)
End Function

But it's only for 2D.

best wishes, Christoph

PS: Yes, its circumcircle, sorry :-)