<<algebra
<<group_elements


(*The routine SpaceA[j] finds the point of symmetry
on the axis of the halfturn A[j].  The routine
PlaneA[j] finds the projection of this point into
the plane.  The routines SpaceB[j] and PlaneB[j] do
the same thing for B[j]*)


PlaneA[j_]:=(z=FixedPoints[A[j]];w=FixedPoints[HA[j]];
PlaneIntersect[z,w])

PlaneB[j_]:=(z=FixedPoints[B[j]];w=FixedPoints[HB[j]];
PlaneIntersect[z,w])

SpaceA[j_]:=(z=FixedPoints[A[j]];w=FixedPoints[HA[j]];
SpaceIntersect[z,w])

SpaceB[j_]:=(z=FixedPoints[B[j]];w=FixedPoints[HB[j]];
SpaceIntersect[z,w])


(*Now we find some of the extra points on our geodesics.
The points we seek are between the symmetry points
defined above and the points defined next.  In all cases,
these "endpoints" are the images, on a certain halfturn
axis, of the symmetry points of another halfturn axis.
This is explained in Ch 5 of the paper.  For instance,
in the first routine when j=0, we are looking at the image of
the symmetry point of A(13) under A(10).  This point
lie in A(0).  

We do not have a formula for the action
of a mobius transformation on H3.  Rather we represent
our points as intersections of two geodesics and
we move the endpoints of these geodesics.
Following this, we recompute the intersection*)


ControlEvenAlphaPlus[j_]:=(
z11=FixedPoints[A[j+13]];
z12=FixedPoints[HA[j+13]]; 
(***********************************
z11 intersect z12 is the symmetry point.
A[j+13] and HA[j+13] commute so that their 
axes intersect.  Now we move these axes by 
mobius transformations
*************************************)
z21=Mobs[A[j+10],z11];
z22=Mobs[A[j+10],z12];
(*now we recompute the intersection point*)
PlaneIntersect[z21,z22])

ControlEvenAlphaMinus[j_]:=(
z11=FixedPoints[A[j-13]];
z12=FixedPoints[HA[j-13]];
z21=Mobs[A[j-10],z11];
z22=Mobs[A[j-10],z12];
PlaneIntersect[z21,z22])

ControlOddAlphaMinus[j_]:=(
z11=FixedPoints[A[j-13]];
z12=FixedPoints[HA[j-13]];
z21=Mobs[A[j-3],z11];
z22=Mobs[A[j-3],z12];
PlaneIntersect[z21,z22])

ControlOddAlphaPlus[j_]:=(
z11=FixedPoints[A[j+13]];
z12=FixedPoints[HA[j+13]];
z21=Mobs[A[j+3],z11];
z22=Mobs[A[j+3],z12];
PlaneIntersect[z21,z22])

ControlBetaPlus[j_]:=(
z11=FixedPoints[B[j+10]];
z12=FixedPoints[HB[j+10]];
z21=Mobs[A[j+5],z11];
z22=Mobs[A[j+5],z12];
PlaneIntersect[z21,z22])

ControlBetaMinus[j_]:=(
z11=FixedPoints[B[j-10]];
z12=FixedPoints[HB[j-10]];
z21=Mobs[A[j-5],z11];
z22=Mobs[A[j-5],z12];
PlaneIntersect[z21,z22])


ControlAlphaMinus[j_]:=(k=Mod[j,2];
If[k==0,ControlEvenAlphaMinus[j],ControlOddAlphaMinus[j]])

ControlAlphaPlus[j_]:=(k=Mod[j,2];
If[k==0,ControlEvenAlphaPlus[j],ControlOddAlphaPlus[j]])


(*now for the points we seek.  In all cases, the points
x,X,Y,y occur in order on the axis of a halfturn.
The points x,y are the endpoints, and lie in the plane.
The point Z is halfway between X and Y in the hyperbolic
metric.  In the case of the Alphas, we then interpolate
between one of the points and Z, getting a point which
is 1/4 or 3/4 of the way from the symmetry point to
one of the control points defined above*)


EvenAlphaMinus[j_]:=(
aa=FixedPoints[A[j]];
x=aa[[1]];
X=ControlAlphaMinus[j];
Y=PlaneA[j];
y=aa[[2]];
Z=HyperbolicInterpolate[x,X,Y,y];
(************************************************
Z is halfway between the control point and the symmetry point
the point we seek is the projection of the point which
is halfway between Z and the same control point. Thus,
the point we seek is the projection of the point which
is 3/4 of the way from the symmetry point to the control point
*****************************************************)
HyperbolicInterpolate[x,X,Z,y])


EvenAlphaPlus[j_]:=(
aa=FixedPoints[A[j]];
x=aa[[1]];
X=PlaneA[j];
Y=ControlAlphaPlus[j];
y=aa[[2]];
Z=HyperbolicInterpolate[x,X,Y,y];
(****************************************
again, the point we seek is 3/4 of the way from the
symmetry point to the control point
**********************************************)
HyperbolicInterpolate[x,Z,Y,y]);


OddAlphaPlus[j_]:=(
aa=FixedPoints[A[j]];
x=aa[[1]];
X=PlaneA[j];
Y=ControlAlphaPlus[j];
y=aa[[2]];
Z=HyperbolicInterpolate[x,X,Y,y];
(****************************************
the point we seek is 1/4 of the way from the
symmetry point to the control point
**********************************************)
HyperbolicInterpolate[x,X,Z,y])


OddAlphaMinus[j_]:=(
aa=FixedPoints[A[j]];
x=aa[[1]];
X=ControlAlphaMinus[j];
Y=PlaneA[j];
y=aa[[2]];
Z=HyperbolicInterpolate[x,X,Y,y];
(****************************************
the point we seek is 1/4 of the way from the
symmetry point to the control point
**********************************************)
HyperbolicInterpolate[x,Z,Y,y]);


AlphaMinus[j_]:=(k=Mod[j,2];
If[k==0,EvenAlphaMinus[j],OddAlphaMinus[j]])

AlphaPlus[j_]:=(k=Mod[j,2];
If[k==0,EvenAlphaPlus[j],OddAlphaPlus[j]])


BetaMinus[j_]:=(
aa=FixedPoints[B[j]];
x=aa[[1]];
X=ControlBetaMinus[j];
Y=PlaneB[j];
y=aa[[2]];
(****************************************
the point we seek is 1/2 of the way from the
symmetry point to the control point
**********************************************)
HyperbolicInterpolate[x,X,Y,y])


BetaPlus[j_]:=(
aa=FixedPoints[B[j]];
x=aa[[1]];
X=PlaneB[j];
Y=ControlBetaPlus[j];
y=aa[[2]];
(****************************************
the point we seek is 1/2 of the way from the
symmetry point to the control point
**********************************************)
HyperbolicInterpolate[x,X,Y,y])

