Geometry
Geometry primitives in WiTwin Core
Overview#
WiTwin Core provides a set of differentiable geometry primitives. All primitives inherit from GeometryBase and expose a to_mesh() method that returns (vertices, faces) as PyTorch tensors.
from witwin.core import Box, Sphere, Cylinder
box = Box(position=(0.0, 0.0, 0.0), size=(1.0, 2.0, 0.5), device="cuda")
vertices, faces = box.to_mesh()Common Base Parameters#
All geometry primitives share these constructor parameters:
| Parameter | Default | Description |
|---|---|---|
position | (0, 0, 0) | Center position in world coordinates |
rotation | None | Optional rotation |
device | None | PyTorch device string |
Box#
An axis-aligned rectangular box.
Box(position=(0.0, 0.0, 1.5), size=(0.25, 4.0, 3.0), device="cuda")| Parameter | Default | Description |
|---|---|---|
size | (1, 1, 1) | Full extent along each axis (width, depth, height) |
Sphere#
A sphere centered at position.
Sphere(position=(0.0, 0.0, 0.0), radius=1.0, device="cuda")| Parameter | Default | Description |
|---|---|---|
radius | 1.0 | Sphere radius |
Cylinder#
A cylinder aligned along a given axis.
Cylinder(position=(0.0, 0.0, 0.0), radius=0.5, height=2.0, axis="z", device="cuda")| Parameter | Default | Description |
|---|---|---|
radius | 1.0 | Cylinder radius |
height | 1.0 | Cylinder height |
axis | "z" | Alignment axis. One of "x", "y", "z" |
Cone#
A cone with apex at the origin and base along a given axis.
Cone(position=(0.0, 0.0, 0.0), radius=1.0, height=2.0, axis="z", device="cuda")| Parameter | Default | Description |
|---|---|---|
radius | 1.0 | Base radius |
height | 1.0 | Height |
axis | "z" | Alignment axis |
Ellipsoid#
An axis-aligned ellipsoid.
Ellipsoid(position=(0.0, 0.0, 0.0), radii=(1.0, 0.5, 0.5), device="cuda")| Parameter | Default | Description |
|---|---|---|
radii | (1, 1, 1) | Semi-axes radii (rx, ry, rz) |
Pyramid#
A square-base pyramid.
Pyramid(position=(0.0, 0.0, 0.0), base_size=1.0, height=2.0, axis="z", device="cuda")| Parameter | Default | Description |
|---|---|---|
base_size | 1.0 | Square base side length |
height | 1.0 | Height |
axis | "z" | Alignment axis |
Prism#
A regular prism with num_sides sides.
Prism(position=(0.0, 0.0, 0.0), radius=1.0, height=2.0, num_sides=6, axis="z", device="cuda")| Parameter | Default | Description |
|---|---|---|
radius | 1.0 | Circumradius |
height | 1.0 | Height |
num_sides | 6 | Number of sides. Must be >= 3 |
axis | "z" | Alignment axis |
Torus#
A torus centered at position.
Torus(position=(0.0, 0.0, 0.0), major_radius=1.0, minor_radius=0.25, axis="z", device="cuda")| Parameter | Default | Description |
|---|---|---|
major_radius | 1.0 | Distance from center to tube center |
minor_radius | 0.25 | Tube radius |
axis | "z" | Normal axis of the torus plane |
HollowBox#
A box with a rectangular hollow interior.
HollowBox(
position=(0.0, 0.0, 0.0),
outer_size=(2.0, 2.0, 2.0),
inner_size=(1.8, 1.8, 1.8),
device="cuda",
)| Parameter | Default | Description |
|---|---|---|
outer_size | (1, 1, 1) | Outer box extent |
inner_size | (0.8, 0.8, 0.8) | Inner hollow extent |
Mesh#
Load arbitrary triangle geometry from vertex and face arrays.
import numpy as np
from witwin.core import Mesh
verts = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0]], dtype=np.float32)
faces = np.array([[0, 1, 2]], dtype=np.int32)
mesh = Mesh(vertices=verts, faces=faces, position=(0.0, 0.0, 0.0), device="cuda")SMPLBody#
A parametric human body geometry based on the SMPL body model. Useful for modeling human blockage in indoor propagation simulations.
from witwin.core import SMPLBodyGeometryBase#
The abstract base class for all geometry primitives. All primitives expose:
geometry.to_mesh(segments=16) — Returns (vertices, faces) as PyTorch tensors. segments controls tessellation quality for curved surfaces.
geometry.signed_distance(xx, yy, zz) — Returns the signed distance field at the given coordinates.
Next Steps#
- Materials API — pair geometry with materials
- Scene API — SceneBase reference