% Diagrams for "triangle solving" % % http://planetmath.org/encyclopedia/TriangleSolving.html % Scale for diagram numeric u, angle_arc_offset, angle_label_offset; u = 2.8cm; angle_arc_offset = 0.15; % given in the units u angle_label_offset = 0.10; % given in the units u line_label_offset = 0.05; % Colors color angle_highlight, angle_unhighlighted; angle_highlight = (0.7, 0.7, 0.9); angle_unhighlighted = white*0.5; % The vertices for the triangle ABC. These may be arbitrary, as long % as the points are given in counter-clockwise order. pair A,B,C; A = (0,0); B = (5/2, 1/4); C = (1/2, 3/2); % Calculates the position to typeset the angle label % in angle ABC given in clockwise orientation. % It uses the cosine law in the encyclopedia entry! vardef angle_inside_position(expr A, B, C, offset) = save a,b,c,cosB,sinB,cosBh,sinBh,T; % Sides of triangle a = abs(C-B); b = abs(A-C); c = abs(B-A); % Get the cosine of the angle B, 0 < B <\pi cosB = (c**2 + a**2 - b**2)/(2*a*c); % Get the sine and cosine of the half-angle B/2, 0 < B/2 < \pi/2. % (Because MetaPost cannot invert trigonemtric functions, directly, % we use the values cos B/2 and sin B/2 to make % the rotation matrix directly.) cosBh = sqrt((cosB+1)/2); sinBh = sqrt((1-cosB)/2); % Transformation which rotates clockwise by angle B/2 at origin transform T; (0,0) transformed T = (0,0); (1,0) transformed T = (cosBh,-sinBh); (0,1) transformed T = (sinBh, cosBh); % Return the mid-way point inside the angle ABC, with given offset B+(offset*(A-B) transformed T) enddef; % Returns an inside arc indicating the angle ABC % given in clockwise orientation. % The computations are similar to those in angle_inside_position. vardef angle_inside_arc(expr A, B, C, offset) = save a,b,c,cosB,sinB,T; % Sides of triangle a = abs(C-B); b = abs(A-C); c = abs(B-A); % Get the cosine and sine of the angle B, 0 < B <\pi cosB = (c**2 + a**2 - b**2)/(2*a*c); sinB = sqrt(1 - cosB**2); % Transformation which rotates clockwise by angle B at origin transform T; (0,0) transformed T = (0,0); (1,0) transformed T = (cosB,-sinB); (0,1) transformed T = (sinB, cosB); % Return the circular arc of angle B centred at B, with radius offset. (B+offset*(A-B)){(A-B) rotated -90} .. (B+(offset*(A-B) transformed T)){(A-B) transformed T rotated -90} enddef; % Returns the midpoint of the given line segment AB with the given % offset, suitable for labelling the line segment. % The orientation of A, B matters: the offset AC shall be the rotation % of AB by 90 degrees clockwise. vardef line_outside_position(expr A, B, offset) = 1/2[A,B] + offset*(B-A) rotated -90 enddef; % Given a circular arc as the path argument arc, % return a circular sector with that arc as the boundary % and the given centre. vardef circular_sector(expr arc, centre) = centre -- arc -- centre .. cycle enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Figure for ASA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% beginfig(1); % Draw the angles path arc; arc := angle_inside_arc(C,A,B, angle_arc_offset); fill circular_sector(arc, A) scaled u withcolor angle_highlight; arc := angle_inside_arc(A,B,C, angle_arc_offset); fill circular_sector(arc, B) scaled u withcolor angle_highlight; arc := angle_inside_arc(B,C,A, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; % Draw the triangle, with highlighted side draw A*u--B*u--C*u--A*u withpen pencircle scaled 0.8; draw A*u--B*u withpen pencircle scaled 2; % Label the angles label(btex $\alpha$ etex, angle_inside_position(C,A,B, angle_label_offset) scaled u); label(btex $\beta$ etex, angle_inside_position(A,B,C, angle_label_offset) scaled u); label(btex $\gamma$ etex, angle_inside_position(B,C,A, angle_label_offset) scaled u); % Label the sides label(btex $a$ etex, line_outside_position(B,C, line_label_offset) scaled u); label(btex $b$ etex, line_outside_position(C,A, line_label_offset) scaled u); label(btex $c$ etex, line_outside_position(A,B, line_label_offset) scaled u); endfig; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Figure for SSS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% beginfig(2); % Draw the angles path arc; arc := angle_inside_arc(C,A,B, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; arc := angle_inside_arc(A,B,C, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; arc := angle_inside_arc(B,C,A, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; % Draw the triangle, with highlighted side draw A*u--B*u--C*u--A*u withpen pencircle scaled 2; % Label the angles label(btex $\alpha$ etex, angle_inside_position(C,A,B, angle_label_offset) scaled u); label(btex $\beta$ etex, angle_inside_position(A,B,C, angle_label_offset) scaled u); label(btex $\gamma$ etex, angle_inside_position(B,C,A, angle_label_offset) scaled u); % Label the sides label(btex $a$ etex, line_outside_position(B,C, line_label_offset) scaled u); label(btex $b$ etex, line_outside_position(C,A, line_label_offset) scaled u); label(btex $c$ etex, line_outside_position(A,B, line_label_offset) scaled u); endfig; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Figure for SAS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% beginfig(3); % Draw the angles path arc; arc := angle_inside_arc(C,A,B, angle_arc_offset); fill circular_sector(arc, A) scaled u withcolor angle_highlight; arc := angle_inside_arc(A,B,C, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; arc := angle_inside_arc(B,C,A, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; % Draw the triangle, with highlighted side draw A*u--B*u--C*u--A*u withpen pencircle scaled 0.8; draw A*u--B*u withpen pencircle scaled 2; draw C*u--A*u withpen pencircle scaled 2; % Label the angles label(btex $\alpha$ etex, angle_inside_position(C,A,B, angle_label_offset) scaled u); label(btex $\beta$ etex, angle_inside_position(A,B,C, angle_label_offset) scaled u); label(btex $\gamma$ etex, angle_inside_position(B,C,A, angle_label_offset) scaled u); % Label the sides label(btex $a$ etex, line_outside_position(B,C, line_label_offset) scaled u); label(btex $b$ etex, line_outside_position(C,A, line_label_offset) scaled u); label(btex $c$ etex, line_outside_position(A,B, line_label_offset) scaled u); endfig; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Figure for SSA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% beginfig(4); % Draw the angles path arc; arc := angle_inside_arc(C,A,B, angle_arc_offset); fill circular_sector(arc, A) scaled u withcolor angle_highlight; arc := angle_inside_arc(A,B,C, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; arc := angle_inside_arc(B,C,A, angle_arc_offset); draw arc scaled u withcolor angle_unhighlighted; % Draw the triangle, with highlighted side draw A*u--B*u--C*u--A*u withpen pencircle scaled 0.8; draw C*u--A*u withpen pencircle scaled 2; draw B*u--C*u withpen pencircle scaled 2; % Label the angles label(btex $\alpha$ etex, angle_inside_position(C,A,B, angle_label_offset) scaled u); label(btex $\beta$ etex, angle_inside_position(A,B,C, angle_label_offset) scaled u); label(btex $\gamma$ etex, angle_inside_position(B,C,A, angle_label_offset) scaled u); % Label the sides label(btex $a$ etex, line_outside_position(B,C, line_label_offset) scaled u); label(btex $b$ etex, line_outside_position(C,A, line_label_offset) scaled u); label(btex $c$ etex, line_outside_position(A,B, line_label_offset) scaled u); endfig; end;