Geometry with Euler
>load geometry
This file contains functions for analytic geometry in the plane. There
are numerical Euler functions, and symbolic Maxima functions.
>setPlotRange(-0.5,2.5,-0.5,2.5);
>A=[1,0]; plotPoint(A,"A");
>B=[0,1]; plotPoint(B,"B");
>C=[2,2]; plotPoint(C,"C");
>plotSegment(A,B,"c");
>plotSegment(B,C,"a");
>plotSegment(C,A,"b");
>lineThrough(B,C)
[ -1 2 2 ]
>ha=perpendicular(A,lineThrough(B,C));
>H=lineIntersection(ha,lineThrough(B,C));
>plotPoint(H,value=1);
>plotSegment(A,H); insimg;

>norm(A-H)*norm(B-C)/2
1.5
>areaTriangle(A,B,C)
1.5
>distance(A,H)
1.3416407865
>degprint(computeAngle(B,C,A))
36°52'11.63''
>c=circleThrough(A,B,C); getCircleRadius(c)
1.17851130198
>plotPoint(getCircleCenter(c),"U");
>plotCircle(c,"Circumcircle"); insimg;

>fracformat; getCircleCenter(c), longformat;
[ 7/6 7/6 ]
>l=angleBisector(A,C,B); g=angleBisector(C,A,B);
>I=lineIntersection(l,g)
[ 0.860379610028 0.860379610028 ]
>color(5); plotLine(l); plotLine(g); color(1);
>plotPoint(I,"I");
>plotCircle(circleWithCenter(I,norm(I-projectToLine(I,lineThrough(A,B)))));
>insimg;

>mxmset(A); mxmset(B); mxmset(C);
>:: c := lineThrough(B,C)
part: invalid index of list or matrix.
#0: turnLeft(v=matrix([2,1]))
#1: lineThrough(a=matrix([0,1]),b=matrix([2,2]))
-- an error. To debug this try: debugmode(true);
>:: getLineEquation(c,x,y), solve(%,y) | expand
c y + c x = c
2 1 3
c c x
3 1
[y = -- - ----]
c c
2 2
>:: getLineEquation(lineThrough(A,[x1,y1]),x,y)
fullmap: arguments must have same formal structure.
#0: lineThrough(a=matrix([1,0]),b=[x1,y1])
-- an error. To debug this try: debugmode(true);
>:: ha := perpendicular(A,lineThrough(B,C))
part: invalid index of list or matrix.
#0: turnLeft(v=matrix([2,1]))
#1: lineThrough(a=matrix([0,1]),b=matrix([2,2]))
-- an error. To debug this try: debugmode(true);
>:: H := lineIntersection(c,ha)
ha c - c ha ha c - c ha
2 3 2 3 1 3 1 3
[- ---------------, ---------------]
ha c - c ha ha c - c ha
1 2 1 2 1 2 1 2
>:: projectToLine(A,lineThrough(B,C))
part: invalid index of list or matrix.
#0: turnLeft(v=matrix([2,1]))
#1: lineThrough(a=matrix([0,1]),b=matrix([2,2]))
-- an error. To debug this try: debugmode(true);
>:: distance(A,H), % | float
fullmap: arguments must have same formal structure.
#0: distance(a=matrix([1,0]),b=[-(ha[2]*c[3]-c[2]*ha[3])/(ha[1]*c[2]-c[1]*ha[2]),(ha[1]*c[3]-c[1]*ha[3])/(ha[1]*c[2]-c[1]*ha[2])])
-- an error. To debug this try: debugmode(true);
ha c - c ha ha c - c ha
2 3 2 3 1 3 1 3
[- ---------------, ---------------]
ha c - c ha ha c - c ha
1 2 1 2 1 2 1 2
>:: cc := circleThrough(A,B,C)
part: invalid index of list or matrix.
#0: turnLeft(v=matrix([-1,1]))
#1: middlePerpendicular(a=matrix([1,0]),b=matrix([0,1]))
#2: circleThrough(a=matrix([1,0]),b=matrix([0,1]),c=matrix([2,2]))
-- an error. To debug this try: debugmode(true);
>:: getCircleRadius(cc) | float
cc
3
>:: computeAngle(A,C,B)
4
acos(-)
5
>:: solve(getLineEquation(angleBisector(A,C,B),x,y),y)[1]
part: invalid index of list or matrix.
#0: turnLeft(v=matrix([-1,1]))
#1: middlePerpendicular(a=matrix([1,0]),b=matrix([0,1]))
#2: angleBisector(a=matrix([1,0]),b=matrix([2,2]),c=matrix([0,1]))
-- an error. To debug this try: debugmode(true);
>:: I := lineIntersection(angleBisector(A,C,B),angleBisector(C,B,A))
part: invalid index of list or matrix.
#0: turnLeft(v=matrix([-1,1]))
#1: middlePerpendicular(a=matrix([1,0]),b=matrix([0,1]))
#2: angleBisector(a=matrix([1,0]),b=matrix([2,2]),c=matrix([0,1]))
-- an error. To debug this try: debugmode(true);
>mxmeval("I")
[ 0.860379610028 0.860379610028 ]
>A=[1,0]; c=circleWithCenter(A,4); B=[1,2]; C=[2,1]; l=lineThrough(B,C);
>setPlotRange(5); plotCircle(c); plotLine(l);
>{P1,P2,f}=lineCircleIntersections(l,c);
>P1, P2,
[ 4.64575131106 -1.64575131106 ]
[ -0.645751311065 3.64575131106 ]
>plotPoint(P1); plotPoint(P2); insimg;

>mxmset(A); mxmset(B); mxmset(C);
>:: c := circleWithCenter(A,4)
part: invalid index of list or matrix.
#0: circleWithCenter(a=matrix([1,0]),r=4)
-- an error. To debug this try: debugmode(true);
>:: l := lineThrough(B,C)
part: invalid index of list or matrix.
#0: turnLeft(v=matrix([1,-1]))
#1: lineThrough(a=matrix([1,2]),b=matrix([2,1]))
-- an error. To debug this try: debugmode(true);
>:: lineCircleIntersections(l,c) | radcan, % | float
2 2 2 2
[[(l sqrt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l ) + l l + c l - l c l )
2 2 1 1 2 2 1 1 1 3 1 2 1 2 2
2 2 2 2 2 2
/(l + l ), - (l sqrt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 1 1 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l ) - l l + c l l - l c )
2 2 1 1 2 2 1 1 2 3 1 1 2 1 2
2 2 2 2 2 2
/(l + l )], [- (l sqrt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 1 2 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l ) - l l - c l + l c l )
2 2 1 1 2 2 1 1 1 3 1 2 1 2 2
2 2 2 2 2 2
/(l + l ), (l sqrt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 1 1 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l ) + l l - c l l + l c )
2 2 1 1 2 2 1 1 2 3 1 1 2 1 2
2 2
/(l + l )]]
2 1
2 2 2 2
[[(l expt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l , 0.5) + l l + c l - l c l )
2 2 1 1 2 2 1 1 1 3 1 2 1 2 2
2 2 2 2 2 2
/(l + l ), - (l expt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 1 1 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l , 0.5) - l l + c l l - l c )
2 2 1 1 2 2 1 1 2 3 1 1 2 1 2
2 2 2 2 2 2
/(l + l )], [- (l expt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 1 2 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l , 0.5) - l l - c l + l c l )
2 2 1 1 2 2 1 1 1 3 1 2 1 2 2
2 2 2 2 2 2
/(l + l ), (l expt(- l + (2 c l + 2 c l ) l + (l + l ) c
2 1 1 3 2 2 1 1 3 2 1 3
2 2 2 2 2
- c l - 2 c l c l - c l , 0.5) + l l - c l l + l c )
2 2 1 1 2 2 1 1 2 3 1 1 2 1 2
2 2
/(l + l )]]
2 1
>C=A+normalize([-2,-3])*4; plotPoint(C); plotSegment(P1,C); plotSegment(P2,C);
>computeAngle(P1,C,P2)
1.20942920289
>C=A+normalize([-4,-3])*4; plotPoint(C); plotSegment(P1,C); plotSegment(P2,C);
>computeAngle(P1,C,P2)
1.20942920289
>insimg;

>A=[2,2]; B=[-1,-2];
>c1=circleWithCenter(A,distance(A,B));
>c2=circleWithCenter(B,distance(A,B));
>{P1,P2,f}=circleCircleIntersections(c1,c2);
>l=lineThrough(P1,P2);
>setPlotRange(5); plotCircle(c1); plotCircle(c2);
>plotPoint(A); plotPoint(B); plotLine(l); insimg;

>:: A:=[a1,a2]; B:=[b1,b2];
>:: c1 := circleWithCenter(A,distance(A,B));
>:: c2 := circleWithCenter(B,distance(A,B));
>:: is := circleCircleIntersections(c1,c2); P1:=is[1]; P2:=is[2];
>:: solve(getLineEquation(lineThrough(P1,P2),x,y),y)
2 2 2 2
(2 b1 - 2 a1) x - b2 - b1 + a2 + a1
[y = - ---------------------------------------]
2 b2 - 2 a2
>:: solve(getLineEquation(middlePerpendicular(A,B),x,y),y)
2 2 2 2
(2 b1 - 2 a1) x - b2 - b1 + a2 + a1
[y = - ---------------------------------------]
2 b2 - 2 a2
Examples Homepage