CAD_PAREA(1)

πŸ“¦
version 7.44.0 Β· 2 versions
, in nixpkgs unstable

πŸŽ€ 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 🫢

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