picogl.core.geometry.sphere

Sphere geometry helpers (pure math, no OpenGL).

Attributes

DEFAULT_SPHERE_STACKS

DEFAULT_SPHERE_SLICES

DEFAULT_SPHERE_RADIUS

sphere_mesh

Classes

SphereGeometrySpec

Parameters controlling sphere mesh generation.

SphereMesh

Build origin-centered sphere geometry from a SphereGeometrySpec.

Functions

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].

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

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

sphere_mesh_np([radius, slices, stacks]) → picogl.renderer.mesh_arrays.MeshArrays

Build a sphere triangle mesh centered at the origin.

generate_indices(v1, v2, v3, v4) → ndarray[Any, dtype[Any]]

generate_normals(cos_lat, cos_lng, sin_lat, sin_lng) → numpy.ndarray[Any, numpy.dtype[Any]]

generate_positions(cos_lat, cos_lng, radius, sin_lat, ...) → ndarray[Any, dtype[Any]]

sphere_mesh_python([radius, slices, stacks]) → picogl.renderer.mesh_arrays.MeshArrays

Build a sphere triangle mesh centered at the origin.

Module Contents

picogl.core.geometry.sphere.DEFAULT_SPHERE_STACKS = 16[source]
picogl.core.geometry.sphere.DEFAULT_SPHERE_SLICES = 16[source]
picogl.core.geometry.sphere.DEFAULT_SPHERE_RADIUS = 1.0[source]
picogl.core.geometry.sphere.iter_longitudes(slices: int) → collections.abc.Iterator[float][source]

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

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

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

picogl.core.geometry.sphere.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.sphere.sphere_mesh_np(radius: float = 1.0, slices: int = 16, stacks: int = 16) → picogl.renderer.mesh_arrays.MeshArrays[source]

Build a sphere triangle mesh centered at the origin.

This is a geometry producer only: it does not instance, color, or batch spheres.

Parameters:
  • radius – Sphere radius.

  • slices – Longitudinal subdivisions.

  • stacks – Latitudinal subdivisions.

Returns:

Origin-centered positions, normals, and triangle indices.

Return type:

MeshArrays

picogl.core.geometry.sphere.generate_indices(v1: numpy.ndarray[Any, Any] | Any, v2: int | Any, v3: int | Any, v4: int | Any) → ndarray[Any, dtype[Any]][source]
picogl.core.geometry.sphere.generate_normals(cos_lat, cos_lng, sin_lat, sin_lng) → numpy.ndarray[Any, numpy.dtype[Any]][source]
picogl.core.geometry.sphere.generate_positions(cos_lat, cos_lng, radius: float, sin_lat, sin_lng) → ndarray[Any, dtype[Any]][source]
picogl.core.geometry.sphere.sphere_mesh_python(radius: float = 1.0, slices: int = 16, stacks: int = 16) → picogl.renderer.mesh_arrays.MeshArrays[source]

Build a sphere triangle mesh centered at the origin.

This is a geometry producer only: it does not instance, color, or batch spheres.

Parameters:
  • radius – Sphere radius

  • slices – Longitudinal subdivisions

  • stacks – Latitudinal subdivisions

Returns:

MeshArrays with origin-centered positions, normals, and triangle indices (no colors)

class picogl.core.geometry.sphere.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[source]
slices: int = 16[source]
stacks: int = 16[source]
class picogl.core.geometry.sphere.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[source]
property vertices_per_item: int[source]

Number of vertices in one sphere instance.

property elements_per_item: int[source]

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.sphere.sphere_mesh[source]