:right-sidebar: True Ray =================================================================== .. currentmodule:: gi.repository.Graphene .. versionadded:: 1.4 .. class:: Ray(*args, **kwargs) :no-contents-entry: A ray emitted from an origin in a given direction. The contents of the ``graphene_ray_t`` structure are private, and should not be modified directly. Constructors ------------ .. rst-class:: interim-class .. class:: Ray :no-index: .. classmethod:: alloc() -> ~gi.repository.Graphene.Ray Allocates a new :obj:`~gi.repository.Graphene.Ray` structure. The contents of the returned structure are undefined. .. versionadded:: 1.4 Methods ------- .. rst-class:: interim-class .. class:: Ray :no-index: .. method:: equal(b: ~gi.repository.Graphene.Ray) -> bool Checks whether the two given :obj:`~gi.repository.Graphene.Ray` are equal. .. versionadded:: 1.4 :param b: a :obj:`~gi.repository.Graphene.Ray` .. method:: free() -> None Frees the resources allocated by :func:`~gi.repository.Graphene.Ray.alloc`. .. versionadded:: 1.4 .. method:: get_closest_point_to_point(p: ~gi.repository.Graphene.Point3D) -> ~gi.repository.Graphene.Point3D Computes the point on the given :obj:`~gi.repository.Graphene.Ray` that is closest to the given point ``p``\. .. versionadded:: 1.4 :param p: a :obj:`~gi.repository.Graphene.Point3D` .. method:: get_direction() -> ~gi.repository.Graphene.Vec3 Retrieves the direction of the given :obj:`~gi.repository.Graphene.Ray`\. .. versionadded:: 1.4 .. method:: get_distance_to_plane(p: ~gi.repository.Graphene.Plane) -> float Computes the distance of the origin of the given :obj:`~gi.repository.Graphene.Ray` from the given plane. If the ray does not intersect the plane, this function returns ``INFINITY``\. .. versionadded:: 1.4 :param p: a :obj:`~gi.repository.Graphene.Plane` .. method:: get_distance_to_point(p: ~gi.repository.Graphene.Point3D) -> float Computes the distance of the closest approach between the given :obj:`~gi.repository.Graphene.Ray` ``r`` and the point ``p``\. The closest approach to a ray from a point is the distance between the point and the projection of the point on the ray itself. .. versionadded:: 1.4 :param p: a :obj:`~gi.repository.Graphene.Point3D` .. method:: get_origin() -> ~gi.repository.Graphene.Point3D Retrieves the origin of the given :obj:`~gi.repository.Graphene.Ray`\. .. versionadded:: 1.4 .. method:: get_position_at(t: float) -> ~gi.repository.Graphene.Point3D Retrieves the coordinates of a point at the distance ``t`` along the given :obj:`~gi.repository.Graphene.Ray`\. .. versionadded:: 1.4 :param t: the distance along the ray .. method:: init(origin: ~gi.repository.Graphene.Point3D | None = None, direction: ~gi.repository.Graphene.Vec3 | None = None) -> ~gi.repository.Graphene.Ray Initializes the given :obj:`~gi.repository.Graphene.Ray` using the given ``origin`` and ``direction`` values. .. versionadded:: 1.4 :param origin: the origin of the ray :param direction: the direction vector .. method:: init_from_ray(src: ~gi.repository.Graphene.Ray) -> ~gi.repository.Graphene.Ray Initializes the given :obj:`~gi.repository.Graphene.Ray` using the origin and direction values of another :obj:`~gi.repository.Graphene.Ray`\. .. versionadded:: 1.4 :param src: a :obj:`~gi.repository.Graphene.Ray` .. method:: init_from_vec3(origin: ~gi.repository.Graphene.Vec3 | None = None, direction: ~gi.repository.Graphene.Vec3 | None = None) -> ~gi.repository.Graphene.Ray Initializes the given :obj:`~gi.repository.Graphene.Ray` using the given vectors. .. versionadded:: 1.4 :param origin: a :obj:`~gi.repository.Graphene.Vec3` :param direction: a :obj:`~gi.repository.Graphene.Vec3` .. method:: intersect_box(b: ~gi.repository.Graphene.Box) -> ~typing.Tuple[~gi.repository.Graphene.RayIntersectionKind, float] Intersects the given :obj:`~gi.repository.Graphene.Ray` ``r`` with the given :obj:`~gi.repository.Graphene.Box` ``b``\. .. versionadded:: 1.10 :param b: a :obj:`~gi.repository.Graphene.Box` .. method:: intersect_sphere(s: ~gi.repository.Graphene.Sphere) -> ~typing.Tuple[~gi.repository.Graphene.RayIntersectionKind, float] Intersects the given :obj:`~gi.repository.Graphene.Ray` ``r`` with the given :obj:`~gi.repository.Graphene.Sphere` ``s``\. .. versionadded:: 1.10 :param s: a :obj:`~gi.repository.Graphene.Sphere` .. method:: intersect_triangle(t: ~gi.repository.Graphene.Triangle) -> ~typing.Tuple[~gi.repository.Graphene.RayIntersectionKind, float] Intersects the given :obj:`~gi.repository.Graphene.Ray` ``r`` with the given :obj:`~gi.repository.Graphene.Triangle` ``t``\. .. versionadded:: 1.10 :param t: a :obj:`~gi.repository.Graphene.Triangle` .. method:: intersects_box(b: ~gi.repository.Graphene.Box) -> bool Checks whether the given :obj:`~gi.repository.Graphene.Ray` ``r`` intersects the given :obj:`~gi.repository.Graphene.Box` ``b``\. See also: :func:`~gi.repository.Graphene.Ray.intersect_box` .. versionadded:: 1.10 :param b: a :obj:`~gi.repository.Graphene.Box` .. method:: intersects_sphere(s: ~gi.repository.Graphene.Sphere) -> bool Checks if the given :obj:`~gi.repository.Graphene.Ray` ``r`` intersects the given :obj:`~gi.repository.Graphene.Sphere` ``s``\. See also: :func:`~gi.repository.Graphene.Ray.intersect_sphere` .. versionadded:: 1.10 :param s: a :obj:`~gi.repository.Graphene.Sphere` .. method:: intersects_triangle(t: ~gi.repository.Graphene.Triangle) -> bool Checks whether the given :obj:`~gi.repository.Graphene.Ray` ``r`` intersects the given :obj:`~gi.repository.Graphene.Triangle` ``b``\. See also: :func:`~gi.repository.Graphene.Ray.intersect_triangle` .. versionadded:: 1.10 :param t: a :obj:`~gi.repository.Graphene.Triangle` Fields ------ .. rst-class:: interim-class .. class:: Ray :no-index: .. attribute:: direction .. attribute:: origin