picogl.core.geometry.sphere =========================== .. py:module:: picogl.core.geometry.sphere .. autoapi-nested-parse:: Sphere geometry helpers (pure math, no OpenGL). Attributes ---------- .. autoapisummary:: picogl.core.geometry.sphere.DEFAULT_SPHERE_STACKS picogl.core.geometry.sphere.DEFAULT_SPHERE_SLICES picogl.core.geometry.sphere.DEFAULT_SPHERE_RADIUS picogl.core.geometry.sphere.sphere_mesh Classes ------- .. autoapisummary:: picogl.core.geometry.sphere.SphereGeometrySpec picogl.core.geometry.sphere.SphereMesh Functions --------- .. autoapisummary:: picogl.core.geometry.sphere.iter_longitudes picogl.core.geometry.sphere.latitude_for_stack picogl.core.geometry.sphere.generate_ring picogl.core.geometry.sphere.sphere_mesh_np picogl.core.geometry.sphere.generate_indices picogl.core.geometry.sphere.generate_normals picogl.core.geometry.sphere.generate_positions picogl.core.geometry.sphere.sphere_mesh_python Module Contents --------------- .. py:data:: DEFAULT_SPHERE_STACKS :value: 16 .. py:data:: DEFAULT_SPHERE_SLICES :value: 16 .. py:data:: DEFAULT_SPHERE_RADIUS :value: 1.0 .. py:function:: iter_longitudes(slices: int) -> collections.abc.Iterator[float] Yield longitude angles for each slice (including closure vertex). .. py:function:: latitude_for_stack(stack: int, stacks: int) -> float Latitude in radians for stack index ``stack`` in ``[0, stacks]``. .. py:function:: generate_ring(radius: float, latitude: float, slices: int) -> list[picogl.core.vec3.Vec3] Vertices on one latitude circle of a sphere centered at the origin. .. py:function:: sphere_mesh_np(radius: float = 1.0, slices: int = 16, stacks: int = 16) -> picogl.renderer.mesh_arrays.MeshArrays Build a sphere triangle mesh centered at the origin. This is a geometry producer only: it does not instance, color, or batch spheres. :param radius: Sphere radius. :param slices: Longitudinal subdivisions. :param stacks: Latitudinal subdivisions. :returns: Origin-centered positions, normals, and triangle indices. :rtype: MeshArrays .. py:function:: generate_indices(v1: numpy.ndarray[Any, Any] | Any, v2: int | Any, v3: int | Any, v4: int | Any) -> ndarray[Any, dtype[Any]] .. py:function:: generate_normals(cos_lat, cos_lng, sin_lat, sin_lng) -> numpy.ndarray[Any, numpy.dtype[Any]] .. py:function:: generate_positions(cos_lat, cos_lng, radius: float, sin_lat, sin_lng) -> ndarray[Any, dtype[Any]] .. py:function:: sphere_mesh_python(radius: float = 1.0, slices: int = 16, stacks: int = 16) -> picogl.renderer.mesh_arrays.MeshArrays Build a sphere triangle mesh centered at the origin. This is a geometry producer only: it does not instance, color, or batch spheres. :param radius: Sphere radius :param slices: Longitudinal subdivisions :param stacks: Latitudinal subdivisions :return: :class:`~picogl.renderer.mesh_arrays.MeshArrays` with origin-centered positions, normals, and triangle indices (no colors) .. py:class:: SphereGeometrySpec Parameters controlling sphere mesh generation. This is configuration only: it does not build geometry. Pass an instance to :class:`SphereMesh`. .. py:attribute:: radius :type: float :value: 1.0 .. py:attribute:: slices :type: int :value: 16 .. py:attribute:: stacks :type: int :value: 16 .. py:class:: SphereMesh(spec: SphereGeometrySpec) Build origin-centered sphere geometry from a :class:`SphereGeometrySpec`. Derived vertex and index counts live here so the spec stays parameters only. :meth:`build` returns colorless :class:`~picogl.renderer.mesh_arrays.MeshArrays`. .. py:attribute:: spec .. py:property:: vertices_per_item :type: int Number of vertices in one sphere instance. .. py:property:: elements_per_item :type: int Number of triangle indices in one sphere instance. .. py:method:: build() -> picogl.renderer.mesh_arrays.MeshArrays Build a sphere template centered at the origin. :return: Positions, normals, and indices with no colors .. py:data:: sphere_mesh