ostk.mathematics.geometry.d3.object.Sphere¶
- class Sphere(
- self: ostk.mathematics.geometry.d3.object.Sphere,
- center: ostk.mathematics.geometry.d3.object.Point,
- radius: ostk.core.type.Real,
- center: ostk.mathematics.geometry.d3.object.Point,
Bases:
Object
Create a 3D sphere with center and radius.
- Parameters:
Example
>>> center = Point(0.0, 0.0, 0.0) >>> sphere = Sphere(center, 1.0)
Methods
Apply a transformation to the sphere in place.
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.
Get the center point of the sphere.
Get the radius of the sphere.
Overloaded function.
Overloaded function.
Check if the object is a cone.
Check if the sphere 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.
Check if the sphere is a unit sphere (radius = 1).
Create an undefined sphere.
Create a unit sphere (radius = 1) at a given center.
- apply_transformation(
- self: ostk.mathematics.geometry.d3.object.Sphere,
- transformation: ostk::mathematics::geometry::d3::Transformation,
Apply a transformation to the sphere in place.
- Parameters:
transformation (Transformation) -- The transformation to apply.
Example
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> transformation = Translation([1.0, 0.0, 0.0]) >>> sphere.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.Sphere, point: ostk.mathematics.geometry.d3.object.Point) -> bool
Check if the sphere contains a point.
- Args:
point (Point): The point to check.
- Returns:
bool: True if the sphere contains the point, False otherwise.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.contains(Point(0.5, 0.5, 0.5)) # True
contains(self: ostk.mathematics.geometry.d3.object.Sphere, point_set: ostk.mathematics.geometry.d3.object.PointSet) -> bool
Check if the sphere contains a point set.
- Args:
point_set (PointSet): The point set to check.
- Returns:
bool: True if the sphere contains the point set, False otherwise.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.contains(PointSet([Point(0.5, 0.5, 0.5), Point(1.0, 1.0, 1.0)])) # True
- get_center( ) ostk.mathematics.geometry.d3.object.Point ¶
Get the center point of the sphere.
- Returns:
The center point of the sphere.
- Return type:
Example
>>> sphere = Sphere(Point(1.0, 2.0, 3.0), 1.0) >>> center = sphere.get_center() # Point(1.0, 2.0, 3.0)
- get_radius( ) ostk.core.type.Real ¶
Get the radius of the sphere.
- Returns:
The radius of the sphere.
- Return type:
Example
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 2.5) >>> radius = sphere.get_radius() # 2.5
- intersection_with(*args, **kwargs)¶
Overloaded function.
intersection_with(self: ostk.mathematics.geometry.d3.object.Sphere, line: ostk.mathematics.geometry.d3.object.Line) -> ostk::mathematics::geometry::d3::Intersection
Check if the sphere intersects a line.
- Args:
line (Line): The line to check intersection with.
- Returns:
bool: True if the sphere intersects the line.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersection_with(Line(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
intersection_with(self: ostk.mathematics.geometry.d3.object.Sphere, ray: ostk.mathematics.geometry.d3.object.Ray, only_in_sight: bool = False) -> ostk::mathematics::geometry::d3::Intersection
Check if the sphere intersects a ray.
- Args:
ray (Ray): The ray to check intersection with. only_in_sight (bool, optional): If true, only return intersection points that are in sight. Defaults to False.
- Returns:
bool: True if the sphere intersects the ray.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersection_with(Ray(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
- intersects(*args, **kwargs)¶
Overloaded function.
intersects(self: ostk.mathematics.geometry.d3.object.Sphere, point: ostk.mathematics.geometry.d3.object.Point) -> bool
Check if the sphere intersects a point.
- Args:
point (Point): The point to check intersection with.
- Returns:
bool: True if the sphere intersects the point.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersects(Point(1.0, 0.0, 0.0)) # True
intersects(self: ostk.mathematics.geometry.d3.object.Sphere, point_set: ostk.mathematics.geometry.d3.object.PointSet) -> bool
Check if the sphere intersects a point set.
- Args:
point_set (PointSet): The point set to check intersection with.
- Returns:
bool: True if the sphere intersects the point set.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersects(PointSet([Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0)])) # True
intersects(self: ostk.mathematics.geometry.d3.object.Sphere, line: ostk.mathematics.geometry.d3.object.Line) -> bool
Check if the sphere intersects a line.
- Args:
line (Line): The line to check intersection with.
- Returns:
bool: True if the sphere intersects the line.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersects(Line(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
intersects(self: ostk.mathematics.geometry.d3.object.Sphere, ray: ostk.mathematics.geometry.d3.object.Ray) -> bool
Check if the sphere intersects a ray.
- Args:
ray (Ray): The ray to check intersection with.
- Returns:
bool: True if the sphere intersects the ray.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersects(Ray(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
intersects(self: ostk.mathematics.geometry.d3.object.Sphere, segment: ostk.mathematics.geometry.d3.object.Segment) -> bool
Check if the sphere intersects a segment.
- Args:
segment (Segment): The segment to check intersection with.
- Returns:
bool: True if the sphere intersects the segment.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersects(Segment(Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0))) # True
intersects(self: ostk.mathematics.geometry.d3.object.Sphere, plane: ostk.mathematics.geometry.d3.object.Plane) -> bool
Check if the sphere intersects a plane.
- Args:
plane (Plane): The plane to check intersection with.
- Returns:
bool: True if the sphere intersects the plane.
- Example:
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.intersects(Plane(Point(1.0, 0.0, 0.0), Vector3d(0.0, 0.0, 1.0))) # True
- 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.Sphere) bool ¶
Check if the sphere is defined.
- Returns:
True if the sphere is defined, False otherwise.
- Return type:
Example
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.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:
- is_unitary(self: ostk.mathematics.geometry.d3.object.Sphere) bool ¶
Check if the sphere is a unit sphere (radius = 1).
- Returns:
True if the sphere has unit radius, False otherwise.
- Return type:
Example
>>> sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0) >>> sphere.is_unitary() # True
- static undefined() ostk.mathematics.geometry.d3.object.Sphere ¶
Create an undefined sphere.
- Returns:
An undefined sphere.
- Return type:
Example
>>> undefined_sphere = Sphere.undefined() >>> undefined_sphere.is_defined() # False
- static unit( ) ostk.mathematics.geometry.d3.object.Sphere ¶
Create a unit sphere (radius = 1) at a given center.
- Parameters:
center (Point) -- The center point of the unit sphere.
- Returns:
A unit sphere centered at the given point.
- Return type:
Example
>>> center = Point(1.0, 2.0, 3.0) >>> unit_sphere = Sphere.unit(center) >>> unit_sphere.get_radius() # 1.0