:right-sidebar: True Sphere =================================================================== .. currentmodule:: gi.repository.Graphene .. versionadded:: 1.2 .. class:: Sphere(*args, **kwargs) :no-contents-entry: A sphere, represented by its center and radius. Constructors ------------ .. rst-class:: interim-class .. class:: Sphere :no-index: .. classmethod:: alloc() -> ~gi.repository.Graphene.Sphere Allocates a new :obj:`~gi.repository.Graphene.Sphere`\. The contents of the newly allocated structure are undefined. .. versionadded:: 1.2 Methods ------- .. rst-class:: interim-class .. class:: Sphere :no-index: .. method:: contains_point(point: ~gi.repository.Graphene.Point3D) -> bool Checks whether the given ``point`` is contained in the volume of a :obj:`~gi.repository.Graphene.Sphere`\. .. versionadded:: 1.2 :param point: a :obj:`~gi.repository.Graphene.Point3D` .. method:: distance(point: ~gi.repository.Graphene.Point3D) -> float Computes the distance of the given ``point`` from the surface of a :obj:`~gi.repository.Graphene.Sphere`\. .. versionadded:: 1.2 :param point: a :obj:`~gi.repository.Graphene.Point3D` .. method:: equal(b: ~gi.repository.Graphene.Sphere) -> bool Checks whether two :obj:`~gi.repository.Graphene.Sphere` are equal. .. versionadded:: 1.2 :param b: a :obj:`~gi.repository.Graphene.Sphere` .. method:: free() -> None Frees the resources allocated by :func:`~gi.repository.Graphene.Sphere.alloc`. .. versionadded:: 1.2 .. method:: get_bounding_box() -> ~gi.repository.Graphene.Box Computes the bounding box capable of containing the given :obj:`~gi.repository.Graphene.Sphere`\. .. versionadded:: 1.2 .. method:: get_center() -> ~gi.repository.Graphene.Point3D Retrieves the coordinates of the center of a :obj:`~gi.repository.Graphene.Sphere`\. .. versionadded:: 1.2 .. method:: get_radius() -> float Retrieves the radius of a :obj:`~gi.repository.Graphene.Sphere`\. .. versionadded:: 1.2 .. method:: init(center: ~gi.repository.Graphene.Point3D | None, radius: float) -> ~gi.repository.Graphene.Sphere Initializes the given :obj:`~gi.repository.Graphene.Sphere` with the given ``center`` and ``radius``\. .. versionadded:: 1.2 :param center: the coordinates of the center of the sphere, or :const:`None` for a center in (0, 0, 0) :param radius: the radius of the sphere .. method:: init_from_points(points: list[~gi.repository.Graphene.Point3D], center: ~gi.repository.Graphene.Point3D | None = None) -> ~gi.repository.Graphene.Sphere Initializes the given :obj:`~gi.repository.Graphene.Sphere` using the given array of 3D coordinates so that the sphere includes them. The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all ``points``\. .. versionadded:: 1.2 :param points: an array of :obj:`~gi.repository.Graphene.Point3D` :param center: the center of the sphere .. method:: init_from_vectors(vectors: list[~gi.repository.Graphene.Vec3], center: ~gi.repository.Graphene.Point3D | None = None) -> ~gi.repository.Graphene.Sphere Initializes the given :obj:`~gi.repository.Graphene.Sphere` using the given array of 3D coordinates so that the sphere includes them. The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all ``vectors``\. .. versionadded:: 1.2 :param vectors: an array of :obj:`~gi.repository.Graphene.Vec3` :param center: the center of the sphere .. method:: is_empty() -> bool Checks whether the sphere has a zero radius. .. versionadded:: 1.2 .. method:: translate(point: ~gi.repository.Graphene.Point3D) -> ~gi.repository.Graphene.Sphere Translates the center of the given :obj:`~gi.repository.Graphene.Sphere` using the ``point`` coordinates as the delta of the translation. .. versionadded:: 1.2 :param point: the coordinates of the translation Fields ------ .. rst-class:: interim-class .. class:: Sphere :no-index: .. attribute:: center .. attribute:: radius