unreal.Ray
¶
- class unreal.Ray(origin: Vector = Ellipsis, direction: Vector = Ellipsis)¶
Bases:
StructBase
3D Ray represented by Origin and (normalized) Direction. note: The full C++ class is located here: EngineSourceRuntimeCorePublicMathRay.h
C++ Source:
Module: CoreUObject
File: NoExportTypes.h
Editor Properties: (see get_editor_property/set_editor_property)
direction
(Vector): [Read-Write]origin
(Vector): [Read-Write]
- get_ray_box_intersection(box) double or None ¶
Check if the Ray intersects a Sphere defined by the SphereCenter and SphereRadius.
- Parameters:
box (Box) –
- Returns:
true if the ray hits the box, and false otherwise
hit_distance (double): Distance along the ray (Ray Parameter) to first intersection point with the Box
- Return type:
double or None
- get_ray_line_closest_point(line_origin, line_direction) -> (double, ray_parameter=double, ray_point=Vector, line_parameter=double, line_point=Vector)¶
Compute the pair of closest points on a 3D Ray and Line. The Line is defined by an Origin and Direction (ie same as a Ray) but extends infinitely in both directions.
- Parameters:
- Returns:
the minimum distance between the Ray and Line, ie between RayPoint and LinePoint
ray_parameter (double): the Ray Parameter of the closest point on the Ray (range 0, inf)
ray_point (Vector): the point on the Ray corresponding to RayParameter
line_parameter (double): the Line parameter of the closest point on the Line (range -inf, inf)
line_point (Vector): the point on the Line corresponding to LineParameter
- Return type:
tuple
- get_ray_parameter(point) double ¶
Project the given Point onto the closest point along the Ray, and return the Ray Parameter/Distance at that Point
- Parameters:
point (Vector) –
- Return type:
double
- get_ray_plane_intersection(plane) double or None ¶
Find the intersection of a Ray and a Plane
- Parameters:
plane (Plane) –
- Returns:
true if the ray hits the plane (only false if ray is parallel with plane)
hit_distance (double): the returned Distance along the ray (Ray Parameter) to intersection point with the Plane
- Return type:
double or None
- get_ray_point(distance) Vector ¶
Get a Point at the given Distance along the Ray (Origin + Distance*Direction)
- Parameters:
distance (double) –
- Return type:
- get_ray_point_distance(point) double ¶
Get the distance from Point to the closest point on the Ray
- Parameters:
point (Vector) –
- Return type:
double
- get_ray_segment_closest_point(seg_start_point, seg_end_point) -> (double, ray_parameter=double, ray_point=Vector, seg_point=Vector)¶
Compute the pair of closest points on a 3D Ray and Line Segment The Line Segment is defined by its two Endpoints.
- Parameters:
- Returns:
the minimum distance between the Ray and Segment, ie between RayPoint and SegPoint
ray_parameter (double): the Ray Parameter of the closest point on the Ray (range 0, inf)
ray_point (Vector): the point on the Ray corresponding to RayParameter
seg_point (Vector): the point on the Segment
- Return type:
tuple
- get_ray_sphere_intersection(sphere_center, sphere_radius) (distance1=double, distance2=double) or None ¶
Check if the Ray intersects a Sphere defined by the SphereCenter and SphereRadius. This function returns two intersection distances (ray parameters). If the ray grazes the sphere, both distances will be the same, and if it misses, they will be MAX_FLOAT. Use the function GetRayPoint to convert the distances to points on the ray/sphere.
- Parameters:
sphere_center (Vector) –
sphere_radius (double) –
- Returns:
true if ray intersects sphere
distance1 (double): Distance along ray (Ray Parameter) to first/closer intersection point with sphere
distance2 (double): Distance along ray (Ray Parameter) to second/further intersection point with sphere
- Return type:
tuple or None
- get_ray_start_end(start_distance=0.000000, end_distance=0.000000) -> (start_point=Vector, end_point=Vector)¶
Get two points along the ray.
- Parameters:
start_distance (double) –
end_distance (double) –
- Returns:
start_point (Vector): returned as Origin + StartDistance*Direction
end_point (Vector): returned as Origin + EndDistance*Direction, Unless EndDistance = 0, then MaxFloat is used as the Distance
- Return type:
tuple