Get the FREE Ultimate OpenClaw Setup Guide →

geometry-primitive-library

npx machina-cli add skill a5c-ai/babysitter/geometry-primitive-library --openclaw
Files (1)
SKILL.md
1.7 KB

Geometry Primitive Library Skill

Purpose

Provide robust implementations of computational geometry primitives with proper handling of edge cases and numerical precision.

Capabilities

  • Point, line, segment, polygon classes
  • Cross product, dot product operations
  • CCW/CW orientation tests
  • Area calculations
  • Intersection tests
  • Distance calculations

Target Processes

  • computational-geometry

Geometric Primitives

Point Operations

  • Point addition, subtraction
  • Scalar multiplication
  • Dot product
  • Cross product
  • Distance calculation

Line/Segment Operations

  • Line-line intersection
  • Segment-segment intersection
  • Point-line distance
  • Point-segment distance
  • Parallel/perpendicular tests

Polygon Operations

  • Area calculation (signed and unsigned)
  • Point in polygon test
  • Polygon centroid
  • Convexity test

Input Schema

{
  "type": "object",
  "properties": {
    "primitive": {
      "type": "string",
      "enum": ["point", "line", "segment", "polygon", "circle"]
    },
    "operations": { "type": "array" },
    "language": {
      "type": "string",
      "enum": ["cpp", "python", "java"]
    },
    "useInteger": { "type": "boolean", "default": false },
    "epsilon": { "type": "number" }
  },
  "required": ["primitive"]
}

Output Schema

{
  "type": "object",
  "properties": {
    "success": { "type": "boolean" },
    "code": { "type": "string" },
    "operations": { "type": "array" },
    "precisionNotes": { "type": "string" }
  },
  "required": ["success", "code"]
}

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/algorithms-optimization/skills/geometry-primitive-library/SKILL.mdView on GitHub

Overview

Provides Point, Line, Segment, and Polygon classes with cross/dot products, CCW tests, area, intersections, and distance calculations. Emphasizes edge-case handling and numerical precision to keep geometry operations reliable in real-world apps.

How This Skill Works

The library exposes core geometric primitives (point, line, segment, polygon) with common operations such as line-line and segment-segment intersections, point-line and point-segment distance, and polygon-area and centroid calculations. It uses explicit epsilon-based tolerance, supports integer-precision mode via useInteger, and returns precise results while handling degeneracies.

When to Use It

  • Detect segment intersections in CAD drawings and routing algorithms
  • Check if a point lies inside a polygon for GIS region queries
  • Compute polygon area and centroid for map features
  • Measure distance from a point to a line or segment in robotics or AR apps
  • Test polygon convexity and orientation for shape analysis

Quick Start

  1. Step 1: Import or instantiate Point, Line, Segment, and Polygon primitives in your language
  2. Step 2: Invoke operations such as intersection, distance, contains, and area
  3. Step 3: Validate results with a defined epsilon and test edge cases

Best Practices

  • Choose useInteger for exact arithmetic when coordinates are integers
  • Tune epsilon to your coordinate scale to avoid false positives
  • Test degenerate cases: zero-length segments, parallel lines, colinear points
  • Validate input primitive type before applying operations
  • Document invariants: orientation sign, area positivity, and polygon simplicity

Example Use Cases

  • Road network: find intersection of two road segments
  • Geofencing: test if a GPS point is inside a polygon boundary
  • Urban planning: compute polygon area and centroid for a land parcel
  • Alignment tool: distance from a point to a construction line
  • Shape analysis: determine if a polygon is convex

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers