Rectangles in the plane: rectangle

### 12.9.3 Rectangles in the plane: rectangle

See section 13.8.3 for rectangles in space.

The rectangle command takes three mandatory arguments and one or two optional arguments. The mandatory arguments are two points A and B and a nonzero real number k.

rectangle returns and draws the rectangle ABCD, where AD=|k|·AB and the angle from AB to AD is counterclockwise if k > 0, clockwise if k<0.
Input:

rectangle(0, 1+i, 1/2)

Output:

Input:

rectangle(0, 1+i, -1/2)

Output:

The optional fourth and fifth arguments need to be variable names which will be assigned to vertices C and D.
Input:

rectangle(0, 1+i, -1/2, C, D)

Output:

Input:

affix(C), affix(D)

Output:

(3 + i)/2, (1 - i)/2

Given rectangle(A,B,k), Xcas computes D by affix(D) = affix(A) + kexp(iπ/2)(affix(B)−affix(A)). If k is complex, then rectangle draws a parallelogram.
Input:

rectangle(0,1,1+i)

Output: