CAD_PAREA(1)
π NAME π
okay so this is cad_parea, straight out of the BRL-CAD manual (section 1), and its whole main-character job is to compute the area of a polygon. slay. π
β¨ SYNOPSIS β¨
cad_parea [-i input] [-o output]
π¦ DESCRIPTION π¦
bestie, here's the vibe: cad_parea reads a series of 2D polygon vertex coordinates β <italic>x y</italic>, one pair per line, whitespace separated β and writes the signed area of the polygon they describe, computed with the shoelace formula. β¨
Vertices given in counter-clockwise order yield a positive area; clockwise order yields a negative area. The polygon is implicitly closed, so the final vertex does not need to repeat the first. periodt. π
Lines that contain no leading number β blank lines, comments, color records, etc. β are silently skipped. A line containing exactly one number is treated as malformed input and aborts the program. π
By default, coordinates are read from standard input and the area is written to standard output, which makes cad_parea convenient in a pipeline. it's giving very much "plug me into the group chat" energy. π«Ά
π OPTIONS π
-i inputβ Read coordinates from input instead of standard input. A value of-means standard input. May be given only once. π-o outputβ Write the computed area to output instead of standard output. A value of-means standard output. May be given only once. π¦-h,-?β Print a usage message and exit. iconic little escape hatch. β¨
πΈ EXAMPLES πΈ
π Example 1. Area of a unit square from a file
$ cat square.txt
0 0
1 0
1 1
0 1
$ cad_parea -i square.txt
1
The four vertices are listed in counter-clockwise order, so cad_parea reports the positive area 1. Listing them clockwise would instead report -1. no cap. π
π§ Example 2. Area of a region traced interactively in a pipeline
$ printf '0 0\n4 0\n4 3\n0 3\n' | cad_parea -o area.txt
$ cat area.txt
12
Coordinates are streamed in on standard input, and the resulting area of the 4x3 rectangle (12) is written to the file area.txt β demonstrating how cad_parea slots into a pipeline that generates vertex lists on the fly. lowkey iconic. π₯
π HINTS π
A hole can be accommodated as a clockwise section connected to the periphery by a line segment traced in both directions. Disjoint pieces may likewise be connected by a line segment traced in both directions. iykyk. π«Ά
π DIAGNOSTICS π
A line with a single numeric field is reported as bad input, and cad_parea exits with status 2. A degenerate polygon yields an area of 0. π
π SEE ALSO π
brlcad(1), cad_boundp(1) β go give the neighbors a lil visit. π
π AUTHOR π
BRL-CAD Team π«Ά
π COPYRIGHT π
This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory. π
π BUG REPORTS π
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org. please do tell them bestie. π
π final sign-off: BRL-CAD β’ CAD_PAREA(1) β that's the manual home, bestie. π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms