Skip to main content

Exact analytical occlusion判定 for convex geometries

Project description

occlusion-geometry

Exact analytical occlusion判定 for convex geometries.

Overview

This library provides exact analytical methods for determining if convex geometric bodies are fully occluded by spherical occluders from a point observer's viewpoint.

The core insight is that for a convex body B to be fully occluded by a sphere S from observer A, B must be completely contained within the "shadow cone" (umbra) formed by A and S.

For cylinders, the library implements the exact quartic equation method derived in the accompanying paper, which reduces the occlusion problem to finding roots of a quartic polynomial via the companion matrix method.

Key Features

  • Exact analytical判定: No approximations or sampling for cylinder occlusion
  • Quartic equation solver: Companion matrix eigenvalue method for numerical stability
  • Multiple geometry support: Cylinders, cones, cuboids, prisms, frustums, and generic convex bodies
  • Coordinate transformations: Automatic alignment to standard cone-oriented frame
  • Comprehensive testing: Numerical validation against dense ray sampling

Installation

pip install -e .

Quick Start

from occlusion_geometry import Point, Sphere, Cylinder, is_fully_occluded

# Define observer, occluder, and occluded body
observer = Point([0, 0, 0])
sphere = Sphere([0, 0, -10], 5)
cylinder = Cylinder([0, 0, -15], [0, 0, 1], 2, 5)

# Check occlusion
is_occluded = is_fully_occluded(observer, sphere, cylinder)
print(f"Cylinder is {'occluded' if is_occluded else 'visible'}")

Mathematical Background

Shadow Cone (Umbra)

For a spherical occluder with center C and radius R, viewed from observer position A, the shadow cone (umbra) is defined by:

  • Apex: Observer position A
  • Axis: Unit vector from A toward C
  • Half-angle: α = arcsin(R / |AC|)

Cylinder Occlusion Criterion

For a cylinder to be fully occluded, both its circular edges must be completely inside the shadow cone. For each circular edge:

  1. Parameterize the circle: P(φ) = C + R·(u·cos(φ) + v·sin(φ))
  2. Find the point with maximum angle to cone axis by solving f'(φ) = 0
  3. Using Weierstrass substitution s = tan(φ/2), this becomes a quartic equation
  4. The cylinder is occluded if the maximum angle ≤ cone half-angle for both edges

Quartic Equation

The critical points are found by solving:

p4·s^4 + p3·s^3 + p2·s^2 + p1·s + p0 = 0

Where coefficients are derived from geometric parameters (see paper for full derivation).

API Reference

Primitives

  • Point(position): 3D point observer
  • Sphere(center, radius): Spherical occluder
  • Cylinder(center, axis, radius, height): Cylindrical body
  • ConeBody(apex, base_center, base_radius): Conical body
  • Cuboid(center, axes, dimensions): Rectangular box
  • Prism(center, axis, n_sides, circumradius, height): Regular N-sided prism
  • Frustum(bottom_center, top_center, bottom_radius, top_radius, n_sides): Truncated pyramid
  • ConvexBody(vertices, support_func): Generic convex body

Main Function

is_fully_occluded(observer, sphere, body, return_details=False)

Returns True if body is fully occluded by sphere from observer's viewpoint.

Testing

Run tests with pytest:

pytest tests/ -v

Numerical Validation

The analytical判定 for cylinders is validated against dense ray sampling (ground truth) with 10,000+ random configurations. The判定 matches ground truth 100% within numerical tolerance.

Project Structure

occlusion-geometry/
├── src/occlusion_geometry/
│   ├── primitives/      # Geometric primitives
│   ├── core/            # Core algorithms (shadow cone, quartic solver)
│   ├── analytic/        # Analytical判定 for each geometry
│   ├── transforms/      # Coordinate transformations
│   └── occlusion.py     # Unified API
├── tests/
│   ├── numerical/       # Numerical validation tests
│   └── test_*.py        # Unit tests
└── benchmarks/          # Performance benchmarks

License

MIT License

Citation

If you use this library in your research, please cite the accompanying paper on analytical occlusion判定.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

occlusion_geometry-0.1.0.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

occlusion_geometry-0.1.0-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file occlusion_geometry-0.1.0.tar.gz.

File metadata

  • Download URL: occlusion_geometry-0.1.0.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for occlusion_geometry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a8e84411d418cb8c6900fdbf5f9c54f3feeb420547d03646d5d73f6cf43819b5
MD5 a6797703da307eb0904928352039ae11
BLAKE2b-256 ae422dad64783826055f3681e5378e29086720642a647cd3572a0926b50a2097

See more details on using hashes here.

File details

Details for the file occlusion_geometry-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for occlusion_geometry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6caa4daee6bd855e0db2aee577817c7048bfda63a72423034468a2e1abd120fe
MD5 4f8e4e8a8b692286d51b965c51255dee
BLAKE2b-256 3033a84600ea11e47f23923ebf32ecb20cacaf0ad6011ebe307575330c723eb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page