### 27.6.3 Right triangles in space

See Section 26.7.3 for right triangles in the plane.

The right_triangle command returns and draws a right triangle. It can take its arguments in two different ways.

1. Three points.
   - right_triangle takes three mandatory arguments and one optional argument:
     - A,B,P, three points.
     - Optionally, var, a variable name.
   - right_triangle(A,B,P⟨,var⟩) returns and draws the right triangle BAC in plane ABP with the right angle at vertex A. The triangle is oriented so that the angle BAC is positive. The length of AC equals the length of AP.

     If the variable name var is given, it will be assigned to the vertex C.

2. Three points and a real number.
   - right_triangle takes mandatory three arguments and one optional argument:
     - A,B, two points.
     - [P,k], a list consisting of a point P and a real number k.
     - Optionally, var, a variable name.
   - right_triangle(A,B,[P,k] ⟨,var⟩) returns and draws the right triangle BAC in plane ABP with the right angle at vertex A, and the length of AC equals |k| times the length of AP. Angles BAC and BAP have the same orientation if k is positive; they have opposite orientation if k is negative. So, if β is the angle ABC, then tan(β)=k.

     If the variable name var is given, it will be assigned to the vertex C.

#### Examples

A,B,P:=point(0,0,0),point(3,3,3),point(0,0,3); right_triangle(A,B,P);

right_triangle(A,B,[P,2])

right_triangle(A,B,[P,-2])

right_triangle(A,B,[P,2],C); coordinates(C)

⎡
⎢
⎣

−3

√

2

,−3

√

2

,6

√

2

⎤
⎥
⎦