Macros for the Poincaré-Geometrie

The following is a file containing all the macros for the Poincaré geometry in the geometry language of C.a.R.

// Macros for the Poincare geometry

macro reflect
// Reflect a point with respect to a circle
	M=point
	parameter k=circle(M) // the basic circle
	parameter P=point // the point to reflect
	g1=line(M,P)
	M1=midpoint(M,P)
	h=plumb(g1,M1)
	A,B=intersection(k,h)
	g2=line(M,A) // so MA = PA
	M2=midpoint(M,A)
	g=plumb(g2,M2)
	target S=intersection(g1,g) // so MS = SA
	// By similarity: MS / r = r / MP
end

macro MS
// Construct the symmetry line for A, B
	parameter A=point
	parameter B=point
	g=line(A,B)
	M=midpoint(A,B)
	target t=plumb(g,M)
end

macro circlethrough
// Construct the circle through three points.
	parameter A=point
	parameter B=point
	parameter C=point
	g1=MS(A,B)
	g2=MS(A,C)
	Mk=intersection(g1,g2)
	target k=circle(Mk,A)
end

macro poincareline
// Construct the line through two points with respect
// to a circle
	M=point
	parameter k=circle(M) // the basic circle
	parameter A=point
	parameter B=point
	AA=reflect(k,A) // now the circle goes through A, B and AA
	target c=circlethrough(A,B,AA)
end

macro poincarecircle
// Construct the circle around A through B with respect
// to a circle
	M=point
	parameter k=circle(M) // the basic circle
	parameter A=point
	parameter B=point
	cc=poincareline(k,A,B)
	g=line(c(cc),B)
	h=plumb(g,B)
	s=line(M,A)
	Mc=intersection(h,s)
	target c=circle(Mc,B)
end

macro poincareMS
// Construct the symmetric line between A and B
// with respect to a circle
	M=point
	parameter k=circle(M) // the basic circle
	parameter A=point
	parameter B=point
	k1=poincarecircle(k,A,B)
	k2=poincarecircle(k,B,A)
	C,D=intersection(k1,k2)
	target g=poincareline(k,C,D)
end

macro poincareintersection
// Construct the intersection between "lines"
// with respect to a circle
	M=point
	MA=point
	MB=point
	parameter k=circle(M) // the basic circle
	parameter g=circle(MA)
	parameter h=circle(MB)
	X,Y=intersection(h,g)
	away(Y,M)
	target X
end

macro poincaremidpoint
// Construct the midpoint beween A and B
// with respect to a circle
	M=point
	parameter k=circle(M) // the basic circle
	parameter A=point
	parameter B=point
	h=poincareMS(k,A,B)
	g=poincareline(k,A,B)
	X=poincareintersection(k,h,g)
	target X
end

macro poincareplumb
// Construct the rectangular through A to g
// with respect to a circle
	M=point
	Mc=point
	D=point
	parameter k=circle(M,5) // the basic circle
	parameter A=point
	parameter g=circle(Mc,D)
	l=line(M,Mc)
	U,V=intersection(l,g)
	away(V,M)
	k1=poincarecircle(k,A,U)
	X,Y=intersection(g,k1)
	h=poincareMS(k,X,Y)
	target h
end

macro poincarecircle3
// Construct a Poincare circle around M with radius AB
	M=point
	parameter k=circle(M) // basic circle
	parameter A=point // First radius point
	parameter B=point // Second radius point
	parameter MC=point // midpoint
	g=poincareline(k,A,MC)
	h=poincareplumb(k,A,g)
	c=poincarecircle(k,A,B)
	X,Y=intersection(c,h)
	U,V=intersection(k,g)
	cp=circlethrough(U,V,X)
	hh=poincareplumb(k,MC,g)
	R,S=intersection(hh,cp)
	away(R,M)
	target ct=poincarecircle(k,MC,S)
Ende

Makro tangent
// Euklid Tangent to a cricle through a point.
	M=point
	parameter c=circle(M) // Circle
	parameter A=point // Point on the circle
	g=line(A,M)
	target t=plumb(g,A)
Ende

Macro poincareangle
// Construct the Poincare angle ABC
	M=point
	parameter k=circle(M) // Basic circle
	parameter A=point // A
	parameter B=point // Basis point B
	parameter C=point // C
	ba=poincareline(k,B,A)
	BA=tangent(ba,B)
	la=plumb(BA,A)
	AA=intersection(BA,la)
	bc=poincareline(k,B,C)
	BC=tangent(bc,B)
	lc=plumb(BC,C)
	CC=intersection(BC,lc)
	target angle(AA,B,CC)
Ende

Makro poincareangleat
// Creates the two angles at D from Poincare line g,
// which are equal to the angle ABC.
	M=point
	parameter k=circle(M) // Basic circle
	parameter A=point // A
	parameter B=point // Basis point B
	parameter C=point // C
	parameter D=point // New basis point D
	Mg=point
	parameter g=circle(Mg) // Line g
	a=poincareangle(k,A,B,C)
	t=tangent(g,D)
	X,Y=intersection(t,k)
	a1=angle(X,D,a)
	DD=reflect(k,D)
	hh=MS(D,DD)
	gg=plumb(a1,D)
	Mt=intersection(hh,gg)
	target circle(Mt,D)
	a2=angle(X,D,-a)
	gg2=plumb(a2,D)
	Mt2=intersection(hh,gg2)
	target circle(Mt2,D)
Ende	



// ***************************************************
// Test:

window(0,0,8)

// The basic circle in green
Mc=point(0,0)
hide(true,Mc)
k=circle(Mc,5)
fill(k)
back(k)
color(green,k)
thickness(thin,k)