Graphene.Ray

Fields

Name

Type

Access

Description

direction

Graphene.Vec3

r

origin

Graphene.Vec3

r

Methods

class

alloc ()

equal (b)

free ()

get_closest_point_to_point (p)

get_direction ()

get_distance_to_plane (p)

get_distance_to_point (p)

get_origin ()

get_position_at (t)

init (origin, direction)

init_from_ray (src)

init_from_vec3 (origin, direction)

intersect_box (b)

intersect_sphere (s)

intersect_triangle (t)

intersects_box (b)

intersects_sphere (s)

intersects_triangle (t)

Details

class Graphene.Ray

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.

New in version 1.4.

classmethod alloc()
Returns:

the newly allocated Graphene.Ray. Use Graphene.Ray.free() to free the resources allocated by this function

Return type:

Graphene.Ray

Allocates a new Graphene.Ray structure.

The contents of the returned structure are undefined.

New in version 1.4.

equal(b)
Parameters:

b (Graphene.Ray) – a Graphene.Ray

Returns:

true if the given rays are equal

Return type:

bool

Checks whether the two given Graphene.Ray are equal.

New in version 1.4.

free()

Frees the resources allocated by Graphene.Ray.alloc().

New in version 1.4.

get_closest_point_to_point(p)
Parameters:

p (Graphene.Point3D) – a Graphene.Point3D

Returns:

return location for the closest point3d

Return type:

res: Graphene.Point3D

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

New in version 1.4.

get_direction()
Returns:

return location for the direction

Return type:

direction: Graphene.Vec3

Retrieves the direction of the given Graphene.Ray.

New in version 1.4.

get_distance_to_plane(p)
Parameters:

p (Graphene.Plane) – a Graphene.Plane

Returns:

the distance of the origin of the ray from the plane

Return type:

float

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

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

New in version 1.4.

get_distance_to_point(p)
Parameters:

p (Graphene.Point3D) – a Graphene.Point3D

Returns:

the distance of the point

Return type:

float

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

New in version 1.4.

get_origin()
Returns:

return location for the origin

Return type:

origin: Graphene.Point3D

Retrieves the origin of the given Graphene.Ray.

New in version 1.4.

get_position_at(t)
Parameters:

t (float) – the distance along the ray

Returns:

return location for the position

Return type:

position: Graphene.Point3D

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

New in version 1.4.

init(origin, direction)
Parameters:
Returns:

the initialized ray

Return type:

Graphene.Ray

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

New in version 1.4.

init_from_ray(src)
Parameters:

src (Graphene.Ray) – a Graphene.Ray

Returns:

the initialized ray

Return type:

Graphene.Ray

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

New in version 1.4.

init_from_vec3(origin, direction)
Parameters:
Returns:

the initialized ray

Return type:

Graphene.Ray

Initializes the given Graphene.Ray using the given vectors.

New in version 1.4.

intersect_box(b)
Parameters:

b (Graphene.Box) – a Graphene.Box

Returns:

the type of intersection

t_out:

the distance of the point on the ray that intersects the box

Return type:

(Graphene.RayIntersectionKind, t_out: float)

Intersects the given Graphene.Ray self with the given Graphene.Box b.

New in version 1.10.

intersect_sphere(s)
Parameters:

s (Graphene.Sphere) – a Graphene.Sphere

Returns:

the type of intersection

t_out:

the distance of the point on the ray that intersects the sphere

Return type:

(Graphene.RayIntersectionKind, t_out: float)

Intersects the given Graphene.Ray self with the given Graphene.Sphere s.

New in version 1.10.

intersect_triangle(t)
Parameters:

t (Graphene.Triangle) – a Graphene.Triangle

Returns:

the type of intersection

t_out:

the distance of the point on the ray that intersects the triangle

Return type:

(Graphene.RayIntersectionKind, t_out: float)

Intersects the given Graphene.Ray self with the given Graphene.Triangle t.

New in version 1.10.

intersects_box(b)
Parameters:

b (Graphene.Box) – a Graphene.Box

Returns:

true if the ray intersects the box

Return type:

bool

Checks whether the given Graphene.Ray self intersects the given Graphene.Box b.

See also: Graphene.Ray.intersect_box()

New in version 1.10.

intersects_sphere(s)
Parameters:

s (Graphene.Sphere) – a Graphene.Sphere

Returns:

true if the ray intersects the sphere

Return type:

bool

Checks if the given Graphene.Ray self intersects the given Graphene.Sphere s.

See also: Graphene.Ray.intersect_sphere()

New in version 1.10.

intersects_triangle(t)
Parameters:

t (Graphene.Triangle) – a Graphene.Triangle

Returns:

true if the ray intersects the triangle

Return type:

bool

Checks whether the given Graphene.Ray self intersects the given Graphene.Triangle b.

See also: Graphene.Ray.intersect_triangle()

New in version 1.10.