Some comments on the Geometry page.

I see now why I was unable to use the area function correctly. I first cut-and-pasted the definition

   area=:[: +/ (-&{: -:@* +&{.)~ Atnp

When I noticed the reference to another definition Atnp, I then pasted that into my session.

So, my attempt to use area gave me the following error:

   area 1 1 _1 _1*-:%:2 0,0 2,2 0,:0 2
|domain error: Atnp
|       area 1 1 _1 _1*-:%:2 0,0 2,2 0,:0 2

Once I defined area again, having previously defined Atnp, it worked fine.

   area=:[: +/ (-&{: -:@* +&{.)~ Atnp
   area 1 1 _1 _1*-:%:2 0,0 2,2 0,:0 2
1

I also defined my own version of this verb, using essentially the same method (Surveyor's Formula) but with an equivalent to Atnp incorporated directly into it.

Signed area that works on 2-column point array:

areapts=: [:([: -:[: +/(0{]) * [:(1&|.-_1&|.) 1{]) |:

   areapts 2 0,2 4,0 4,:0 0         NB. 2x4 square
8

DevonMcCormick/Geometry2 (last edited 2009-10-14 13:53:19 by DevonMcCormick)