crater-rs

Crates.iocrater-rs
lib.rscrater-rs
version0.8.0
created_at2024-10-02 22:55:38.600762+00
updated_at2025-07-14 23:54:10.904893+00
descriptionA library for N-dimensional arbitrary geometries
homepage
repositoryhttps://gitlab.com/games1122013/crater.rs
max_upload_size
id1394712
size6,351,101
Clyde Huibregtse (ClydeHuibregtse)

documentation

README

crater.rs

logo

High-performance N-dimensional geometric modeling and analysis in Rust

⚠️ Pre-1.0 Development ⚠️
The API is evolving rapidly. Breaking changes may occur until version 1.0.0.

Overview

crater.rs is a powerful library for N-dimensional geometric modeling and computational analysis, built on the Burn machine learning framework. It enables GPU-accelerated geometric computations with support for CPU, CUDA, Metal, and WebGPU backends.

Interactive Gallery

Experience crater.rs in action with our interactive raycast gallery featuring mesh extraction.

Key Features

Constructive Solid Geometry (CSG)

  • N-dimensional field operations with GPU acceleration via Burn tensors
  • Implicit surface modeling using scalar field functions f(x₁, x₂, ..., xₙ) ≤ 0
  • Boolean operations (union, intersection, difference) with R-function smoothness
  • Coordinate transformations (translation, rotation, scaling) with automatic differentiation

High-Performance Ray Casting

  • Batch ray-surface intersection with 100k+ rays/second throughput
  • AABB acceleration structures for complex geometries
  • Multi-backend support (CPU, CUDA, Metal, WebGPU)
  • Interactive visualization with real-time mesh overlays

3D Mesh Generation

  • Marching Cubes algorithm for isosurface extraction
  • Export support for STL, VTK, and other formats
  • Paraview integration for scientific visualization
  • High-resolution meshing with quality controls

Geometric Analysis

  • Surface analysis (normals, gradients, curvature)
  • Volume calculations for closed and open regions
  • Trajectory analysis for ray-based simulations
  • Interactive galleries for algorithm visualization

Quick Start

Add crater.rs to your project:

cargo add crater-rs

Basic Example

use crater::csg::prelude::*;
use burn::backend::wgpu::Wgpu;

// Create a 3D sphere
let device = Default::default();
let sphere = Field3D::<Wgpu>::sphere(2.0, device);

// Convert to implicit surface region
let region = sphere.into_isosurface(0.0).region();

// Generate mesh using marching cubes
let mesh = marching_cubes(&MarchingCubesParams {
    region,
    bounds: BoundingBox::new([-3.0; 3], [3.0; 3]),
    resolution: (32, 32, 32),
    algebra: Algebra::default(),
}, &device);

Interactive Gallery

Run the interactive raycast gallery locally:

cargo run --example raycast-gallery --release

Then open raycast-gallery.html in your browser to explore ray casting with real-time mesh visualization.

Applications

Real-World Usage

  • phlux.rs - Monte Carlo neutron transport for nuclear reactor physics
    • Uses crater.rs ray casting for particle tracking in complex reactor geometries

Use Cases

  • Scientific Computing: Volumetric analysis, surface extraction, field visualization
  • Computer Graphics: Procedural modeling, collision detection, mesh generation
  • Engineering: CAD operations, finite element preprocessing, geometric optimization
  • Research: Algorithm development, computational geometry, physics simulation

Documentation

  • Book - Comprehensive guide with theory and examples
  • API Docs - Complete API reference with examples
  • Examples - Working code samples and tutorials

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 89

cargo fmt