Chapter 15. Non-Euclidean Geometry on the Half-Plane
Rovenski Vladimir, Haifa
> restart:
15.2 Examples of Visualization
Example 1 . Let us plot the segment (the straight line) through two given points.
> segment:= proc(A, B) local x0,R,t1,t2,X,Y; if A[1]=B[1] then plot([[A,B], [[A[1],0], [A[1],2*max(A[2],B[2])]]],scaling=constrained,thickness=[2,1],linestyle=[1,2]) else x0:=solve((B[1]-x)^2+B[2]^2=(A[1]-x)^2+A[2]^2,x); R:=sqrt((B[1]-x0)^2+B[2]^2); X:=x0+R*cos(t); Y:=R*sin(t); t1:=arccos((B[1]-x0)/R); t2:=arccos((A[1]-x0)/R); plot([[X,Y,t=t1..t2],[X,Y,t=0..Pi]],scaling=constrained, thickness=[2,1], linestyle=[1,2]) fi end:
> segment([2,3], [3,2]); # segment([2,3], [2,2]);
> plots[display]([seq(segment([0,1],[i/4,0]),i=-4..4)]);
The procedure segment is used below.
Example 2 . One can derive the distance between points A_1(x_1,y_1) and A_2(x_2,y_2)
The following procedure distance basing on the formula (15.1) is used below.
> distance:= proc(A, B) local x0,R,t1,t2,F; if A[1]=B[1] then RETURN(abs(log(B[2]/A[2]))) else x0:=solve((B[1]-x)^2+B[2]^2=(A[1]-x)^2+A[2]^2,x); R:=sqrt((B[1]-x0)^2+B[2]^2); t1:=arccos((B[1]-x0)/R); t2:=arccos((A[1]-x0)/R); F:=t -> ln(tan(t/2)); RETURN(evalf(abs(F(t2)-F(t1)))) fi end:
> distance([0,20], [0,.05]);
Example 3 . We plot a triangle with given vertices using the procedure triangle .
> triangle:= proc(A,B,C) local text; text:=plots[textplot]({[A[1],A[2],`a`],[B[1],B[2],`b`],[C[1],C[2],`c`]},align=ABOVE); plots[display]([segment(A,B),segment(B,C),segment(A,C)],text) end:
> triangle([1,1],[5,2],[4,4]);
Derive its perimeter using the procedure perimeter .
> perimeter:= proc(A,B,C) evalf(distance(A,B)+distance(C,B)+distance(A,C)) end:
> perimeter([1,1], [2,1], [5,4]);
Example 4 . We calculate angles of a triangle using the procedure angle .
> _angle:= proc(B, A, C) local x_AB,x_AC,R_AB,R_AC; if C[1]<>A[1] then x_AC:=solve((C[1]-x)^2+C[2]^2=(A[1]-x)^2+A[2]^2,x); R_AC:=sqrt((A[1]-x_AC)^2+A[2]^2) fi; if B[1]<>A[1] then x_AB:=solve((B[1]-x)^2+B[2]^2=(A[1]-x)^2+A[2]^2,x); R_AB:=sqrt((A[1]-x_AB)^2+A[2]^2) fi; if C[1]=A[1] and B[1]=A[1] then RETURN(0) elif B[1]=A[1] and C[1]<>A[1] then RETURN(evalf(arccos((x_AC-A[1])/R_AC))) elif C[1]=A[1] and B[1]<>A[1] then RETURN(evalf(arccos((x_AB-A[1])/R_AB))) else RETURN(evalf(arccos((R_AB^2+R_AC^2-(x_AB-x_AC)^2)/(2*R_AB*R_AC)))) fi end:
> _angle([1,1], [1,2], [2,3]);
Calculate the sum of its angles, and the area using the procedure sum_angles .
> sum_angles:= proc(A,B,C) evalf(_angle(B,A,C)+_angle(A,B,A)+_angle(B,C,A)) end:
> sum_angles([1,1], [3,1], [2,1]);
Example 5 . ( Polygons ). Let us plot a square (right quadrangle) with edge a.
Plot quadrangles using the following procedure.
>
lambert:= proc(a1,a2) local t1,p,A,B,C,F,R1,x1,phi,text;
if evalf(abs(sinh(a1)*sinh(a2)))>=1 then no_solutions
else A:=[0,1]; B:=[0,exp(a2)]; t1:=2*arctan(exp(-a1));
C:=[cos(t1),sin(t1)]; R1:=tan(t1); x1:=1/cos(t1);
F[1]:=(exp(2*a2)-R1^2+x1^2)/(2*x1); F[2]:=sqrt(exp(2*a2)-F[1]^2); F:=[F[1], F[2]];
phi:=angle(B,F,C); p[1]:=segment(A, B); p[2]:=segment(A, C); p[3]:=segment(B, F); p[4]:=segment(C, F);
text:=plots[textplot]({[A[1],A[2],`a`],[B[1],B[2],`b`],[C[1],C[2],`c`], [F[1],F[2],`f`]}, align=LEFT); plots[display]({seq(p[i],i=1..4), text}, axes=framed, title=convert(angle_f=evalf(phi*180/Pi),string)) fi end:
> lambert(0.7, 1); # Lambert
> plots[display](lambert(0.7,1), lambert(-0.7,1)); # Sacceri
Example 6 . Let us deduce the formula for the angle of parallelism
> F:=t->k*ln(tan(t/2)): alpha=solve(F(Pi/2)-F(t)=d, t);
> T:=Pi/6: p[1]:=segment([0,1],[cos(T),sin(T)]): p[2]:=segment([cos(T),sin(T)],[cos(T),sin(T)+1]): p[3]:=plot([[0,0],[cos(T), sin(T)]]): p[4]:=segment([0,0],[0,2]): p[5]:=plots[textplot]({[cos(T)-.1,sin(T)+.3,`t`],[0.4,.1,`t`],[.3,1.1,`d`]},align=RIGHT): plots[display](seq(p[i], i=1..5));
Plot right and left parallels to a given straight line through a given point usiong the procedure parallel .
Calculate the angle between them and the angle of parallelism.
> parallel:=proc(A,P,Q) local x1,R1,g,AB1,AB2,B1,B2, phi,T;if P[1]=Q[1] then B1:=[P[1],0]; B2:=[A[1],A[2]+1] else x1:=solve((P[1]-x)^2+P[2]^2=(Q[1]-x)^2+Q[2]^2,x);R1:=sqrt((P[1]-x1)^2+P[2]^2);B1:=[x1-R1,0];B2:=[x1+R1,0] fi;AB1:=segment(A,B1); AB2:=segment(A,B2);T:=plots[textplot]({[A[1],A[2],`a`],[P[1],P[2],`p`],[Q[1],Q[2],`q`]},align=ABOVE); g:=segment(P,Q); phi:=_angle(B1,A,B2)/2; plots[display]([AB1,AB2,g,T],title=convert(`angle of parallelism`=phi,string)) end:
> parallel([3,5], [5,2], [2,4]);
Example 7 . P lot the perpendicular to a given straight line through a given point and derive its length
(i.e., the distance from the point to the line) using the procedure perp .
> perp:=proc(A,P,Q) local x1,x2,R1,R2,PQ,AB,B,d,T;if P[1]=Q[1] then B:=[P[1], sqrt(A[1]^2+A[2]^2)] else x1:=solve((P[1]-x)^2+P[2]^2=(Q[1]-x)^2+Q[2]^2,x);R1:=sqrt((P[1]-x1)^2+P[2]^2);x2:=solve((A[1]-x)^2+A[2]^2=(x-x1)^2-R1^2,x);R2:=sqrt((A[1]-x2)^2+A[2]^2);B[1]:=solve(R1^2-(x1-x)^2=R2^2-(x2-x)^2,x);B[2]:=sqrt(R1^2-(x1-B[1])^2); B:=[B[1],B[2]] fi; T:=plots[textplot]({[A[1],A[2],`a`], [B[1],B[2],`b`],[P[1],P[2],`p`], [Q[1],Q[2],`q`]}, align=ABOVE); PQ:=segment(P,Q); AB:=segment(A,B); d:=distance(A,B); plots[display]([AB,PQ,T],title=convert(distance=d,string)) end:
> perp([-7,1], [5,2], [2,4]);
>
Example 8 . Let us plot the common perpendicular to given "antiparallel" (non-parallel and non intersected) lines.
In the program we assume that the straight lines AB and CD are "antiparallel".
> biortho:=proc(A,B,P,Q) local x0,x1,R1,x2,R2,x3,R3,g,x_E,x_F,H,K,d,T;if A[1]<>B[1] then x1:=solve((A[1]-x)^2+A[2]^2=(B[1]-x)^2+B[2]^2,x); R1:=sqrt((A[1]-x1)^2+A[2]^2) fi; if P[1]<>Q[1] then x2:=solve((P[1]-x)^2+P[2]^2=(Q[1]-x)^2+Q[2]^2,x); R2:=sqrt((P[1]-x2)^2+P[2]^2) fi; if A[1]=B[1] then x3:=A[1]; R3:=sqrt((x3-x2)^2-R2^2); K[1]:=x3; K[2]:=R3; H[1]:=-1/2*(-x2^2+x3^2-R3^2+R2^2)/(x2-x3); H[2]:=sqrt(R3^2-(H[1]-x3)^2) elif P[1]=Q[1] then x3:=P[1]; R3:=sqrt((x3-x1)^2-R1^2); H[1]:=x3; H[2]:=R3; K[1]:=-1/2*(-x1^2+x3^2-R3^2+R1^2)/(x1-x3); K[2]:=sqrt(R3^2-(K[1]-x3)^2) else if R1=R2 then x3:=(x1+x2)/2 else x0:=solve((x1-x)/R1=(x2-x)/R2,x); x_E:=x1-R1^2/(x1-x0); x_F:=x2-R2^2/(x2-x0); x3:=(x_E+x_F)/2 fi; R3:=sqrt((x3-x1)^2-R1^2); K[1]:=-1/2*(-x1^2+x3^2-R3^2+R1^2)/(x1-x3); H[1]:=-1/2*(-x2^2+x3^2-R3^2+R2^2)/(x2-x3); K[2]:=sqrt(R3^2-(K[1]-x3)^2); H[2]:=sqrt(R3^2-(H[1]-x3)^2) fi; H:=[H[1],H[2]]; K:=[K[1],K[2]]; d:=distance(H,K); T:=plots[textplot]({[A[1],A[2],`a`], [B[1],B[2],`b`],[P[1],P[2],`p`], [Q[1],Q[2],`q`],[H[1],H[2],`h`], [K[1],K[2],`k`]},align=ABOVE); g||1:=segment(A,B); g||2:=segment(P,Q); g||3:=segment(H,K); RETURN(plots[display]([g||1, g||2, g||3, T], title=convert(distance=d, string))) end:
> biortho([1,1], [5,3], [11,1], [14,3]);
The procedure for -transversals can be the following.
> transversal:= proc(A,B,P,Q,theta) local x1,R1,x2,R2,x3,R3,H,K,g,s,d,i,j,text; if A[1]<>B[1] then x1:=solve((A[1]-x)^2+A[2]^2=(B[1]-x)^2+B[2]^2, x); R1:=sqrt((A[1]-x1)^2+A[2]^2) fi; if P[1]<>Q[1] then x2:=solve((P[1]-x)^2+P[2]^2=(Q[1]-x)^2+Q[2]^2, x); R2:=sqrt((P[1]-x2)^2+P[2]^2) fi; for i from 0 to 1 do for j from 0 to 1 do x3:='x3': R3:='R3': if A[1]=B[1] then solve({(A[1]-x3)/R3=evalf((-1)^i*cos(theta)), (R2^2+R3^2-(x2-x3)^2)/(2*R2*R3)=evalf((-1)^j*cos(theta)), R3>0}, {x3,R3}); assign(%); H[1]:=A[1]: H[2]:=sqrt(R3^2-(A[1]-x3)^2); K[1]:=solve(R3^2-(x3-x)^2=R2^2-(x2-x)^2, x); K[2]:=sqrt(R2^2-(x2-K[1])^2) elif P[1]=Q[1] then solve({(P[1]-x3)/R3=evalf((-1)^i*cos(theta)), (R1^2+R3^2-(x1-x3)^2)/(2*R1*R3)=evalf((-1)^j*cos(theta)), R3>0}, {x3,R3}); assign(%); K[1]:=P[1]: K[2]:=sqrt(R3^2-(P[1]-x3)^2); H[1]:=solve(R3^2-(x3-x)^2=R1^2-(x1-x)^2, x); H[2]:=sqrt(R1^2-(x1-H[1])^2) else solve({(R1^2+R3^2-(x1-x3)^2)/(2*R1*R3)=evalf((-1)^i*cos(theta)), (R2^2+R3^2-(x2-x3)^2)/(2*R2*R3)=evalf((-1)^j*cos(theta)), R3>0}, {x3,R3}); assign(%); H[1]:=solve(R3^2-(x3-x)^2=R1^2-(x1-x)^2, x); H[2]:=sqrt(R1^2-(x1-H[1])^2); K[1]:=solve(R3^2-(x3-x)^2=R2^2-(x2-x)^2, x); K[2]:=sqrt(R2^2-(x2-K[1])^2) fi; H:=[H[1],H[2]]; K:=[K[1],K[2]]; s[i+2*j]:=segment(H,K); d[i+2*j]:=distance(H,K) od od; g||1:=segment(A,B); g||2:=segment(P,Q); text:=plots[textplot]({[A[1],A[2],`a`],[B[1],B[2],`b`],[P[1],P[2],`p`],[Q[1],Q[2],`q`]},align=ABOVE); plots[display]([g||1,g||2,seq(s[i],i=0..3), text],title=convert(dist=[d[1],d[2]],string)) end:
> transversal([-4,0],[-1,0],[1,0],[3,1], Pi/3);
> transversal([2,2],[5,1],[7,5],[7,1], Pi/3);
>
Example 9 . Pencils of lines and their orthogonal trajectories.
> circle_L:=proc(A,R) local P1,P2,yE,R1,AA,text;yE:=A[2]*cosh(R); R1:=A[2]*sinh(R); AA:=plottools[point](A,symbol=circle); P1:=plottools[circle]([A[1],yE],R1,thickness=2); P2:=segment([A[1]-A[2],0],[A[1]+A[2],0]); text:=plots[textplot]({[A[1],A[2],`a`]},align=ABOVE); plots[display]([P1,AA,P2,text],scaling=constrained) end:
> plots[display]([seq(circle_L([3,1],i/5), i=1..5),seq(segment([3,1],[3+i/4,0]), i=-3..3)]);
> n:=10:plots[display]([seq(circle_L([.3,1],i/n), i=1..n),seq(circle_L([-.3,1], i/n), i=1..n)]);
> equid:=proc(A,B,d) local x1,R,i,p,n,xi,Ri,ti,y1,y2,R2,T;n:=4; if A[1]=B[1] then x1:=A[1]; y1:=max(A[2], B[2])+1; y2:=2*arctan(exp(-d)); p[0]:=plot([x1,t, t=0..y1], thickness=2); p[n]:=plot(tan(y2)*(x-x1), x=x1-y1..x1+y1, y=0..y1,thickness=3); for i from 1 to n-1 do Ri:=y1*i/n; p[i]:=plot([x1+Ri*cos(t),Ri*sin(t),t=0..Pi],linestyle=2) od else x1:=solve((B[1]-x)^2+B[2]^2=(A[1]-x)^2+A[2]^2,x); R:=sqrt((B[1]-x1)^2+B[2]^2); for i from 1 to n-1 do ti:=Pi*i/(2*n); xi:=x1+R*cos(ti)+R*sin(ti)*tan(ti); Ri:=sqrt((x1+R*cos(ti)-xi)^2+(R*sin(ti))^2); p[i]:=plot([[xi+Ri*cos(t), Ri*sin(t), t=0..Pi],[2*x1-xi+Ri*cos(t),Ri*sin(t), t=0..Pi]], linestyle=2) od;p[0]:=plot([x1+R*cos(t),R*sin(t), t=0..Pi], thickness=2); y1:=R*exp(d); y2:=(y1^2-R^2)/(2*y1); R2:=y1-y2; p[n]:=plot([x1+R2*cos(t), y2+R2*sin(t),t=-arcsin(y2/R2)..Pi+arcsin(y2/R2)], thickness=3) fi; T:=plots[textplot]({[A[1],A[2],`a`],[B[1],B[2],`b`]},align=ABOVE); plots[display]([seq(p[i],i=0..n),T],scaling=constrained) end:
> equid([1,1],[1,3], 1); equid([1,1],[2,3], 1.6);
> plots[display]({equid([1,1],[2,3],2), equid([1,1],[2,3],-2)});
>
(3)
> plots[coordplot](tangent, title=`Tangential`, scaling=constrained);
> horoc:=proc(A,B) local x0,x1,R,i,p,n,xi,Ri,ti,y2,R2,text; n:=4; if A[1]=B[1] then x1:=A[1]; R:=max(A[2],B[2])+1; R2:=A[2]/2; p[0]:=plot([x1,t,t=0..R],thickness=2) else x0:=solve((B[1]-x)^2+B[2]^2=(A[1]-x)^2+A[2]^2,x); R:=sqrt((B[1]-x0)^2+B[2]^2); x1:=x0+R; R2:=solve(y^2=(A[1]-x1)^2+(A[2]-y)^2,y); p[0]:=plot([x0+R*cos(t),R*sin(t),t=0..Pi],thickness=2) fi; p[n]:=plottools[circle]([x1,R2],R2, thickness=3); for i from 1 to n-1 do Ri:=R*i/n; p[i]:=plot([[x1+Ri+Ri*cos(t),Ri*sin(t), t=0..Pi], [x1-Ri+Ri*cos(t),Ri*sin(t),t=0..Pi]], linestyle=2) od; text:=plots[textplot]({[A[1],A[2],`a`], [B[1],B[2],`b`]},align=ABOVE); plots[display]([seq(p[i], i=0..n), text],scaling=constrained) end:
> horoc([2,3],[2,1]); horoc([6,3],[1,2]);
> plots[display]({horoc([4,3],[1,2]), horoc([1,2],[4,3])});
>
Example 10 . There is an interesting generalization of the construction of the equidistant.
> fifth:=proc(A,B,a) local n,i,p,x,s,P,q,x1,R1,x2,R2,T,F; q[0]:=segment(A,B); n:=8: if A[1]=B[1] then T:=solve((x(s)-t-A[1])^2+y(s)^2-t^2/cos(a)^2,t)[1];for i from 1 to n do p[i]:=dsolve({diff(x(s),s)=x(s)-T-A[1],diff(y(s),s)=y(s),x(0)=A[1],y(0)=i},{x(s),y(s)},type=numeric,method=classical); P[i]:=plots[odeplot](p[i],[x(s),y(s)],-3..2/i); q[i]:=plot([A[1]+i*cot(a)+i/sin(a)*cos(t),i/sin(a)*sin(t), t=0..Pi], linestyle=2) od; plots[display](seq(P[i],i=1..n), seq(q[i],i=0..n)) else x1:=solve((B[1]-x)^2+B[2]^2=(A[1]-x)^2+A[2]^2,x); R1:=sqrt((B[1]-x1)^2+B[2]^2); for i from 1 to n-1 do R2:=R1*sin(a*i/n)/sin(a-a*i/n); x2:=x1+R1*cos(a*i/n)+R1*sin(a*i/n)*cot(a-a*i/n); q[i]:=plot([x2+R2*cos(t),R2*sin(t),t=0..Pi],linestyle=2); R2:=R1*sin(a+(Pi-a)*i/n)/sin((Pi-a)*i/n); x2:=x1+R1*cos(a+(Pi-a)*i/n)+R1*sin(a+(Pi-a)*i/n)*cot(-(Pi-a)*i/n); q[-i]:=plot([x2+R2*cos(t),R2*sin(t),t=0..Pi]) od; P[n]:=plots[polygonplot]([[x1+R1*cos(a),0],[x1+R1*cos(a),4*R1*sin(a)]]); T:=solve((x(s)-t-2*R1)^2+y(s)^2-t^2/cos(a)^2,t)[1]; F:=plottools[transform]((x,y)->[x/(x^2+y^2),y/(x^2+y^2)]); for i from 2 to n-1 do p[i]:=dsolve({diff(x(s),s)=x(s)-T-2*R1,diff(y(s),s)=y(s),x(0)=-2*R1,y(0)=i},{x(s),y(s)},type=numeric, method=classical); P[i]:=plottools[translate](plottools[scale](F(plots[odeplot](p[i],[x(s),y(s)],-3..1,scaling=constrained)),4*R1^2,4*R1^2),x1-R1,0) od; plots[display](seq(P[i],i=2..n), seq(q[i],i=1-n..n-1),scaling=constrained) fi end:
> fifth([-5,0],[5,0],Pi/2-.4); fifth([5,0],[5,5],Pi/2-.4);
>