ostk.mathematics.geometry.d3.object.Polygon

class Polygon(
self: ostk.mathematics.geometry.d3.object.Polygon,
polygon: ostk.mathematics.geometry.d2.object.Polygon,
origin: ostk.mathematics.geometry.d3.object.Point,
x_axis: numpy.ndarray[numpy.float64[3, 1]],
y_axis: numpy.ndarray[numpy.float64[3, 1]],
)

Bases: Object

A polygon in 3D space.

A Polygon is a planar figure defined by a 2D polygon and its position and orientation in 3D space.

Construct a 3D polygon from a 2D polygon and coordinate frame.

Parameters:
  • polygon (Polygon2d) -- The 2D polygon.

  • origin (Point) -- The origin of the polygon in 3D space.

  • x_axis (numpy.ndarray) -- The x-axis direction of the polygon's local frame.

  • y_axis (numpy.ndarray) -- The y-axis direction of the polygon's local frame.

Example

>>> polygon2d = Polygon2d([Point2d(0.0, 0.0), Point2d(1.0, 0.0), Point2d(1.0, 1.0), Point2d(0.0, 1.0)])
>>> origin = Point(0.0, 0.0, 0.0)
>>> x_axis = numpy.array([1.0, 0.0, 0.0])
>>> y_axis = numpy.array([0.0, 1.0, 0.0])
>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)

Methods

apply_transformation

Apply a transformation to the polygon in place.

as_cone

Convert the object to a cone.

as_ellipsoid

Convert the object to an ellipsoid.

as_line

Convert the object to a line.

as_line_string

Convert the object to a line string.

as_plane

Convert the object to a plane.

as_point

Convert the object to a point.

as_point_set

Convert the object to a point set.

as_polygon

Convert the object to a polygon.

as_pyramid

Convert the object to a pyramid.

as_ray

Convert the object to a ray.

as_segment

Convert the object to a segment.

as_sphere

Convert the object to a sphere.

contains

Check if this object contains another object.

get_edge_at

Get the edge at a given index.

get_edge_count

Get the number of edges in the polygon.

get_normal_vector

Get the normal vector of the polygon's plane.

get_origin

Get the origin point of the polygon.

get_polygon2d

Get the 2D polygon representation.

get_vertex_at

Get the vertex at a given index.

get_vertex_count

Get the number of vertices in the polygon.

get_vertices

Get all vertices of the polygon.

get_x_axis

Get the x-axis direction of the polygon's local frame.

get_y_axis

Get the y-axis direction of the polygon's local frame.

intersects

Check if this object intersects another object.

is_cone

Check if the object is a cone.

is_defined

Check if the polygon is defined.

is_ellipsoid

Check if the object is an ellipsoid.

is_line

Check if the object is a line.

is_line_string

Check if the object is a line string.

is_near

Check if another polygon is near this one within a tolerance.

is_plane

Check if the object is a plane.

is_point

Check if the object is a point.

is_point_set

Check if the object is a point set.

is_polygon

Check if the object is a polygon.

is_pyramid

Check if the object is a pyramid.

is_ray

Check if the object is a ray.

is_segment

Check if the object is a segment.

is_sphere

Check if the object is a sphere.

undefined

Create an undefined polygon.

apply_transformation(
self: ostk.mathematics.geometry.d3.object.Polygon,
transformation: ostk::mathematics::geometry::d3::Transformation,
) None

Apply a transformation to the polygon in place.

Parameters:

transformation (Transformation) -- The transformation to apply.

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> transformation = Transformation.identity()
>>> polygon.apply_transformation(transformation)
as_cone(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Cone

Convert the object to a cone.

Returns:

The cone.

Return type:

Cone

as_ellipsoid(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Ellipsoid

Convert the object to an ellipsoid.

Returns:

The ellipsoid.

Return type:

Ellipsoid

as_line(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Line

Convert the object to a line.

Returns:

The line.

Return type:

Line

as_line_string(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::LineString

Convert the object to a line string.

Returns:

The line string.

Return type:

LineString

as_plane(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Plane

Convert the object to a plane.

Returns:

The plane.

Return type:

Plane

as_point(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Point

Convert the object to a point.

Returns:

The point.

Return type:

Point

as_point_set(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::PointSet

Convert the object to a point set.

Returns:

The point set.

Return type:

PointSet

as_polygon(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Polygon

Convert the object to a polygon.

Returns:

The polygon.

Return type:

Polygon

as_pyramid(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Pyramid

Convert the object to a pyramid.

Returns:

The pyramid.

Return type:

Pyramid

as_ray(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Ray

Convert the object to a ray.

Returns:

The ray.

Return type:

Ray

as_segment(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Segment

Convert the object to a segment.

Returns:

The segment.

Return type:

Segment

as_sphere(
self: ostk.mathematics.geometry.d3.Object,
) ostk::mathematics::geometry::d3::object::Sphere

Convert the object to a sphere.

Returns:

The sphere.

Return type:

Sphere

contains(
self: ostk.mathematics.geometry.d3.Object,
arg0: ostk.mathematics.geometry.d3.Object,
) bool

Check if this object contains another object.

Parameters:

object (Object) -- The object to check containment of.

Returns:

True if this object contains the other object.

Return type:

bool

Example

>>> object = Cone(Point(1.0, 2.0, 3.0), [0.0, 0.0, 1.0], Angle.degrees(30.0))
>>> other_object = Point(1.0, 2.0, 3.1)
>>> object.contains(other_object)  # True
get_edge_at(
self: ostk.mathematics.geometry.d3.object.Polygon,
index: int,
) ostk.mathematics.geometry.d3.object.Segment

Get the edge at a given index.

Parameters:

index (int) -- The index of the edge.

Returns:

The edge segment.

Return type:

Segment

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_edge_at(0)
get_edge_count(self: ostk.mathematics.geometry.d3.object.Polygon) int

Get the number of edges in the polygon.

Returns:

The number of edges.

Return type:

int

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_edge_count()
get_normal_vector(
self: ostk.mathematics.geometry.d3.object.Polygon,
) numpy.ndarray[numpy.float64[3, 1]]

Get the normal vector of the polygon's plane.

Returns:

The normal vector.

Return type:

numpy.ndarray

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_normal_vector()
get_origin(
self: ostk.mathematics.geometry.d3.object.Polygon,
) ostk.mathematics.geometry.d3.object.Point

Get the origin point of the polygon.

Returns:

The origin point.

Return type:

Point

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_origin()
get_polygon2d(
self: ostk.mathematics.geometry.d3.object.Polygon,
) ostk.mathematics.geometry.d2.object.Polygon

Get the 2D polygon representation.

Returns:

The 2D polygon.

Return type:

Polygon2d

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_polygon2d()
get_vertex_at(
self: ostk.mathematics.geometry.d3.object.Polygon,
index: int,
) ostk.mathematics.geometry.d3.object.Point

Get the vertex at a given index.

Parameters:

index (int) -- The index of the vertex.

Returns:

The vertex point.

Return type:

Point

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_vertex_at(0)
get_vertex_count(self: ostk.mathematics.geometry.d3.object.Polygon) int

Get the number of vertices in the polygon.

Returns:

The number of vertices.

Return type:

int

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_vertex_count()
get_vertices(
self: ostk.mathematics.geometry.d3.object.Polygon,
) list[ostk.mathematics.geometry.d3.object.Point]

Get all vertices of the polygon.

Returns:

Array of vertex points.

Return type:

list[Point]

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_vertices()
get_x_axis(
self: ostk.mathematics.geometry.d3.object.Polygon,
) numpy.ndarray[numpy.float64[3, 1]]

Get the x-axis direction of the polygon's local frame.

Returns:

The x-axis vector.

Return type:

numpy.ndarray

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_x_axis()
get_y_axis(
self: ostk.mathematics.geometry.d3.object.Polygon,
) numpy.ndarray[numpy.float64[3, 1]]

Get the y-axis direction of the polygon's local frame.

Returns:

The y-axis vector.

Return type:

numpy.ndarray

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.get_y_axis()
intersects(
self: ostk.mathematics.geometry.d3.Object,
arg0: ostk.mathematics.geometry.d3.Object,
) bool

Check if this object intersects another object.

Parameters:

object (Object) -- The object to check intersection with.

Returns:

True if the objects intersect.

Return type:

bool

Example

>>> object = Cone(Point(1.0, 2.0, 3.0), [0.0, 0.0, 1.0], Angle.degrees(30.0))
>>> other_object = Point(1.0, 2.0, 3.1)
>>> object.intersects(other_object)  # 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:

bool

is_defined(self: ostk.mathematics.geometry.d3.object.Polygon) bool

Check if the polygon is defined.

Returns:

True if the polygon is defined.

Return type:

bool

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.is_defined()
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:

bool

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:

bool

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:

bool

is_near(
self: ostk.mathematics.geometry.d3.object.Polygon,
polygon: ostk.mathematics.geometry.d3.object.Polygon,
tolerance: ostk.core.type.Real,
) bool

Check if another polygon is near this one within a tolerance.

Parameters:
  • polygon (Polygon) -- The polygon to compare against.

  • tolerance (float) -- The maximum distance for polygons to be considered near.

Returns:

True if the polygons are near each other.

Return type:

bool

Example

>>> polygon = Polygon(polygon2d, origin, x_axis, y_axis)
>>> polygon.is_near(polygon, 0.0)
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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

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:

bool

static undefined() ostk.mathematics.geometry.d3.object.Polygon

Create an undefined polygon.

Returns:

An undefined polygon.

Return type:

Polygon

Example

>>> undefined_polygon = Polygon.undefined()
>>> undefined_polygon.is_defined()  # False