Checking whether an object in the plane is a right triangle or a rectangle

### 26.15.7 Checking whether an object in the plane is a right triangle or a rectangle

See Section 27.11.11 for checking for right triangles and rectangles in 3D geometry.

The is_rectangle command determines whether or not a geometric object is a rectangle or right triangle.

- is_rectangle takes G, a geometric object or a sequence of three or four points assumed to be the vertices of a triangle or a quadrilateral.
- is_rectangle(G) returns:
  - (for triangle G) 1, 2 or 3 if G is a right triangle (the number indicates which vertex has the right angle).
  - (for quadrilateral G) 1 if G is a rectangle but not a square.
  - (for quadrilateral G) 2 if G is square.
  - 0 otherwise.

#### Examples

is_rectangle(1,1+i,i)

2 |  |  |  |  |  |  |  |  |  |

is_rectangle(1+i,-2+i,-2-i,1-i)

1 |  |  |  |  |  |  |  |  |  |

R:=rectangle(-2-i,1-i,3,C,D); is_rectangle(R[0])

1 |  |  |  |  |  |  |  |  |  |

Note that R[0] is a rectangle since R is a list made of a rectangle and vertices C and D.

affix(C,D)

−2+8 i,1+8 i |  |  |  |  |  |  |  |  |  |