Ray#

Added in version 1.4.

class Ray(*args, **kwargs)#

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#

class Ray
classmethod alloc() Ray#

Allocates a new Ray structure.

The contents of the returned structure are undefined.

Added in version 1.4.

Methods#

class Ray
equal(b: Ray) bool#

Checks whether the two given Ray are equal.

Added in version 1.4.

Parameters:

b – a Ray

free() None#

Frees the resources allocated by alloc().

Added in version 1.4.

get_closest_point_to_point(p: Point3D) Point3D#

Computes the point on the given Ray that is closest to the given point p.

Added in version 1.4.

Parameters:

p – a Point3D

get_direction() Vec3#

Retrieves the direction of the given Ray.

Added in version 1.4.

get_distance_to_plane(p: Plane) float#

Computes the distance of the origin of the given Ray from the given plane.

If the ray does not intersect the plane, this function returns INFINITY.

Added in version 1.4.

Parameters:

p – a Plane

get_distance_to_point(p: Point3D) float#

Computes the distance of the closest approach between the given 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.

Added in version 1.4.

Parameters:

p – a Point3D

get_origin() Point3D#

Retrieves the origin of the given Ray.

Added in version 1.4.

get_position_at(t: float) Point3D#

Retrieves the coordinates of a point at the distance t along the given Ray.

Added in version 1.4.

Parameters:

t – the distance along the ray

init(origin: Point3D | None = None, direction: Vec3 | None = None) Ray#

Initializes the given Ray using the given origin and direction values.

Added in version 1.4.

Parameters:
  • origin – the origin of the ray

  • direction – the direction vector

init_from_ray(src: Ray) Ray#

Initializes the given Ray using the origin and direction values of another Ray.

Added in version 1.4.

Parameters:

src – a Ray

init_from_vec3(origin: Vec3 | None = None, direction: Vec3 | None = None) Ray#

Initializes the given Ray using the given vectors.

Added in version 1.4.

Parameters:
  • origin – a Vec3

  • direction – a Vec3

intersect_box(b: Box) Tuple[RayIntersectionKind, float]#

Intersects the given Ray r with the given Box b.

Added in version 1.10.

Parameters:

b – a Box

intersect_sphere(s: Sphere) Tuple[RayIntersectionKind, float]#

Intersects the given Ray r with the given Sphere s.

Added in version 1.10.

Parameters:

s – a Sphere

intersect_triangle(t: Triangle) Tuple[RayIntersectionKind, float]#

Intersects the given Ray r with the given Triangle t.

Added in version 1.10.

Parameters:

t – a Triangle

intersects_box(b: Box) bool#

Checks whether the given Ray r intersects the given Box b.

See also: intersect_box()

Added in version 1.10.

Parameters:

b – a Box

intersects_sphere(s: Sphere) bool#

Checks if the given Ray r intersects the given Sphere s.

See also: intersect_sphere()

Added in version 1.10.

Parameters:

s – a Sphere

intersects_triangle(t: Triangle) bool#

Checks whether the given Ray r intersects the given Triangle b.

See also: intersect_triangle()

Added in version 1.10.

Parameters:

t – a Triangle

Fields#

class Ray
direction#
origin#