>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary

18. Geometry

We will illustrate the topic of coordinate geometry by defining functions for polygons in two dimensions that give the displacements between adjacent vertices, the length of sides, the semiperimeter, and the area based on Heron’s formula.

We also present a more general definition for area that not only gives the signed area (positive if the vertices appear in counter-clockwise order), but also applies to polyhedra in higher dimensions (in which case the name area might better be replaced by volume). This definition is based on the use of the determinant applied to a square matrix obtained by bordering a table of vertices t by a final row of the values %!#t . Thus:
```   (length=: +/&.*:) 5 12
13

disp=: ] - 1&|."1
sides=: length@disp
semiper=: -:@(+/)@sides
HERON=: %:@(*/)@(semiper - 0: , sides)
area=: -/ . * @ (] , %@!@#)

t=: 0 0 4 ,: 3 4 7
(];(1&|."1);disp;sides;semiper;HERON;area) t
+-----+-----+-------+-----+---------+---------------+--+
|0 0 4|0 4 0| 0 _4 4|0 4 4|0.5 3.5 4|2.29129 0j0.5 0|_2|
|3 4 7|4 7 3|_1 _3 4|1 3 4|         |               |  |
+-----+-----+-------+-----+---------+---------------+--+

tet1=:6 0 3 0,3 6 5 8,:7 4 0 5
tet2=: 0,.=i.3 3
tet1;(area tet1);tet2;(area tet2)
+-------+----+-------+---------+
|6 0 3 0|11.5|0 1 0 0|_0.166667|
|3 6 5 8|    |0 0 1 0|         |
|7 4 0 5|    |0 0 0 1|         |
+-------+----+-------+---------+
```

>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary