ostk.mathematics.geometry.d3.object.Ray¶
- class Ray(
- self: ostk.mathematics.geometry.d3.object.Ray,
- origin: ostk.mathematics.geometry.d3.object.Point,
- direction: numpy.ndarray[numpy.float64[3, 1]],
- origin: ostk.mathematics.geometry.d3.object.Point,
Bases:
ObjectCreate a 3D ray with specified origin and direction.
- Parameters:
origin (Point) -- The origin point of the ray.
direction (numpy.array) -- The direction vector of the ray.
Example
>>> origin = Point(0.0, 0.0, 0.0) >>> direction = numpy.array([1.0, 0.0, 0.0]) >>> ray = Ray(origin, direction)
Methods
Apply a transformation to the ray.
Convert the object to a cone.
Convert the object to an ellipsoid.
Convert the object to a line.
Convert the object to a line string.
Convert the object to a plane.
Convert the object to a point.
Convert the object to a point set.
Convert the object to a polygon.
Convert the object to a pyramid.
Convert the object to a ray.
Convert the object to a segment.
Convert the object to a sphere.
Overloaded function.
Calculate the distance from the ray to a point.
Get the direction vector of the ray.
Get the origin point of the ray.
Overloaded function.
Overloaded function.
Check if the object is a cone.
Check if the ray is defined.
Check if the object is an ellipsoid.
Check if the object is a line.
Check if the object is a line string.
Check if the object is a plane.
Check if the object is a point.
Check if the object is a point set.
Check if the object is a polygon.
Check if the object is a pyramid.
Check if the object is a ray.
Check if the object is a segment.
Check if the object is a sphere.
Create an undefined ray.
- apply_transformation(
- self: ostk.mathematics.geometry.d3.object.Ray,
- transformation: ostk::mathematics::geometry::d3::Transformation,
Apply a transformation to the ray.
- Parameters:
transformation (Transformation) -- The transformation to apply.
Example
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> transformation = Transformation.translation([1.0, 0.0]) >>> ray.apply_transformation(transformation)
- as_cone( ) ostk::mathematics::geometry::d3::object::Cone¶
Convert the object to a cone.
- Returns:
The cone.
- Return type:
- as_ellipsoid( ) ostk::mathematics::geometry::d3::object::Ellipsoid¶
Convert the object to an ellipsoid.
- Returns:
The ellipsoid.
- Return type:
- as_line( ) ostk::mathematics::geometry::d3::object::Line¶
Convert the object to a line.
- Returns:
The line.
- Return type:
- as_line_string( ) ostk::mathematics::geometry::d3::object::LineString¶
Convert the object to a line string.
- Returns:
The line string.
- Return type:
- as_plane( ) ostk::mathematics::geometry::d3::object::Plane¶
Convert the object to a plane.
- Returns:
The plane.
- Return type:
- as_point( ) ostk::mathematics::geometry::d3::object::Point¶
Convert the object to a point.
- Returns:
The point.
- Return type:
- as_point_set( ) ostk::mathematics::geometry::d3::object::PointSet¶
Convert the object to a point set.
- Returns:
The point set.
- Return type:
- as_polygon( ) ostk::mathematics::geometry::d3::object::Polygon¶
Convert the object to a polygon.
- Returns:
The polygon.
- Return type:
- as_pyramid( ) ostk::mathematics::geometry::d3::object::Pyramid¶
Convert the object to a pyramid.
- Returns:
The pyramid.
- Return type:
- as_ray( ) ostk::mathematics::geometry::d3::object::Ray¶
Convert the object to a ray.
- Returns:
The ray.
- Return type:
- as_segment( ) ostk::mathematics::geometry::d3::object::Segment¶
Convert the object to a segment.
- Returns:
The segment.
- Return type:
- as_sphere( ) ostk::mathematics::geometry::d3::object::Sphere¶
Convert the object to a sphere.
- Returns:
The sphere.
- Return type:
- contains(*args, **kwargs)¶
Overloaded function.
contains(self: ostk.mathematics.geometry.d3.object.Ray, point: ostk.mathematics.geometry.d3.object.Point) -> bool
Check if the ray contains a point.
- Args:
point (Point): The point to check.
- Returns:
bool: True if the ray contains the point, False otherwise.
- Example:
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> ray.contains(Point(2.0, 0.0, 0.0)) # True (point on ray)
contains(self: ostk.mathematics.geometry.d3.object.Ray, point_set: ostk.mathematics.geometry.d3.object.PointSet) -> bool
Check if the ray contains a point set.
- Args:
point_set (PointSet): The point set to check.
- Returns:
bool: True if the ray contains the point set, False otherwise.
- distance_to( ) ostk.core.type.Real¶
Calculate the distance from the ray to a point.
- Parameters:
point (Point) -- The point to calculate distance to.
- Returns:
The minimum distance from the ray to the point.
- Return type:
Example
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> distance = ray.distance_to(Point(1.0, 1.0, 0.0)) # 1.0
- get_direction( ) numpy.ndarray[numpy.float64[3, 1]]¶
Get the direction vector of the ray.
- Returns:
The normalized direction vector of the ray.
- Return type:
Vector3d
Example
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> direction = ray.get_direction() # [1.0, 0.0, 0.0]
- get_origin( ) ostk.mathematics.geometry.d3.object.Point¶
Get the origin point of the ray.
- Returns:
The origin point of the ray.
- Return type:
Example
>>> ray = Ray(Point(1.0, 2.0, 3.0), numpy.array([1.0, 0.0, 0.0])) >>> origin = ray.get_origin() # Point(1.0, 2.0, 3.0)
- intersection_with(*args, **kwargs)¶
Overloaded function.
intersection_with(self: ostk.mathematics.geometry.d3.object.Ray, plane: ostk::mathematics::geometry::d3::object::Plane) -> ostk::mathematics::geometry::d3::Intersection
Compute the intersection of the ray with a plane.
- Args:
plane (Plane): The plane to intersect with.
- Returns:
Intersection: The intersection of the ray with the plane.
- Example:
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([0.0, 0.0, -1.0])) >>> plane = Plane(Point(0.0, 0.0, 0.0), numpy.array([0.0, 0.0, 1.0])) >>> intersection = ray.intersection_with(plane) >>> intersection.get_point() # Point(0.0, 0.0, 0.0)
intersection_with(self: ostk.mathematics.geometry.d3.object.Ray, sphere: ostk::mathematics::geometry::d3::object::Sphere, only_in_sight: bool = False) -> ostk::mathematics::geometry::d3::Intersection
Compute the intersection of the ray with a sphere.
- Args:
sphere (Sphere): The sphere to intersect with. only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to True.
- Returns:
Intersection: The intersection of the ray with the sphere.
- Example:
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> intersection = ray.intersection_with(sphere) >>> intersection.get_point() # Point(0.0, 0.0, 0.0)
intersection_with(self: ostk.mathematics.geometry.d3.object.Ray, ellipsoid: ostk::mathematics::geometry::d3::object::Ellipsoid, only_in_sight: bool = False) -> ostk::mathematics::geometry::d3::Intersection
Compute the intersection of the ray with an ellipsoid.
- Args:
ellipsoid (Ellipsoid): The ellipsoid to intersect with. only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to True.
- Returns:
Intersection: The intersection of the ray with the ellipsoid.
- Example:
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> ellipsoid = Ellipsoid(Point(0.0, 0.0, 0.0), 1.0, 1.0, 1.0) >>> intersection = ray.intersection_with(ellipsoid) >>> intersection.get_point() # Point(0.0, 0.0, 0.0)
- intersects(*args, **kwargs)¶
Overloaded function.
intersects(self: ostk.mathematics.geometry.d3.object.Ray, point: ostk.mathematics.geometry.d3.object.Point) -> bool
intersects(self: ostk.mathematics.geometry.d3.object.Ray, plane: ostk::mathematics::geometry::d3::object::Plane) -> bool
intersects(self: ostk.mathematics.geometry.d3.object.Ray, sphere: ostk::mathematics::geometry::d3::object::Sphere) -> bool
intersects(self: ostk.mathematics.geometry.d3.object.Ray, ellipsoid: ostk::mathematics::geometry::d3::object::Ellipsoid) -> bool
- is_cone(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a cone.
- Returns:
True if the object is a cone.
- Return type:
- is_defined(self: ostk.mathematics.geometry.d3.object.Ray) bool¶
Check if the ray is defined.
- Returns:
True if the ray is defined, False otherwise.
- Return type:
Example
>>> ray = Ray(Point(0.0, 0.0, 0.0), numpy.array([1.0, 0.0, 0.0])) >>> ray.is_defined() # True
- is_ellipsoid(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is an ellipsoid.
- Returns:
True if the object is an ellipsoid.
- Return type:
- is_line(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a line.
- Returns:
True if the object is a line.
- Return type:
- is_line_string(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a line string.
- Returns:
True if the object is a line string.
- Return type:
- is_plane(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a plane.
- Returns:
True if the object is a plane.
- Return type:
- is_point(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a point.
- Returns:
True if the object is a point.
- Return type:
- is_point_set(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a point set.
- Returns:
True if the object is a point set.
- Return type:
- is_polygon(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a polygon.
- Returns:
True if the object is a polygon.
- Return type:
- is_pyramid(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a pyramid.
- Returns:
True if the object is a pyramid.
- Return type:
- is_ray(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a ray.
- Returns:
True if the object is a ray.
- Return type:
- is_segment(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a segment.
- Returns:
True if the object is a segment.
- Return type:
- is_sphere(self: ostk.mathematics.geometry.d3.Object) bool¶
Check if the object is a sphere.
- Returns:
True if the object is a sphere.
- Return type:
- static undefined() ostk.mathematics.geometry.d3.object.Ray¶
Create an undefined ray.
- Returns:
An undefined ray object.
- Return type:
Example
>>> undefined_ray = Ray.undefined() >>> undefined_ray.is_defined() # False