picogl.core.geometry

Pure geometry helpers.

Submodules

Attributes

sphere_mesh

Classes

SphereGeometrySpec

Parameters controlling sphere mesh generation.

SphereMesh

Build origin-centered sphere geometry from a SphereGeometrySpec.

Functions

generate_ring(radius, latitude, slices) → list[picogl.core.vec3.Vec3]

Vertices on one latitude circle of a sphere centered at the origin.

iter_longitudes(slices) → collections.abc.Iterator[float]

Yield longitude angles for each slice (including closure vertex).

latitude_for_stack(stack, stacks) → float

Latitude in radians for stack index stack in [0, stacks].

Package Contents

class picogl.core.geometry.SphereGeometrySpec[source]

Parameters controlling sphere mesh generation.

This is configuration only: it does not build geometry. Pass an instance to SphereMesh.

radius: float = 1.0
slices: int = 16
stacks: int = 16
class picogl.core.geometry.SphereMesh(spec: SphereGeometrySpec)[source]

Build origin-centered sphere geometry from a SphereGeometrySpec.

Derived vertex and index counts live here so the spec stays parameters only. build() returns colorless MeshArrays.

spec
property vertices_per_item: int

Number of vertices in one sphere instance.

property elements_per_item: int

Number of triangle indices in one sphere instance.

build() → picogl.renderer.mesh_arrays.MeshArrays[source]

Build a sphere template centered at the origin.

Returns:

Positions, normals, and indices with no colors

picogl.core.geometry.generate_ring(radius: float, latitude: float, slices: int) → list[picogl.core.vec3.Vec3][source]

Vertices on one latitude circle of a sphere centered at the origin.

picogl.core.geometry.iter_longitudes(slices: int) → collections.abc.Iterator[float][source]

Yield longitude angles for each slice (including closure vertex).

picogl.core.geometry.latitude_for_stack(stack: int, stacks: int) → float[source]

Latitude in radians for stack index stack in [0, stacks].

picogl.core.geometry.sphere_mesh[source]