Geometry Structure and Algorithm#

Geometry Structure#

const float visionflow::geometry::kPi = 3.14159265358979F#

Constant PI.

class IGeometry#

Common abstract base class for all plane geometry types.

Subclassed by visionflow::geometry::Arc2f, visionflow::geometry::Circle2i, visionflow::geometry::ISurface, visionflow::geometry::Line2f, visionflow::geometry::LineString2f, visionflow::geometry::LineString2i, visionflow::geometry::MultiPoint2f, visionflow::geometry::MultiPoint2i, visionflow::geometry::MultiPolygon2i, visionflow::geometry::MultiSegment2f, visionflow::geometry::Point2f, visionflow::geometry::Point2i, visionflow::geometry::Polygon2i, visionflow::geometry::Radian, visionflow::geometry::Ray2f, visionflow::geometry::Ray2i, visionflow::geometry::Rect2i, visionflow::geometry::Ring2i, visionflow::geometry::RotateRect2i, visionflow::geometry::Segment2f, visionflow::geometry::Segment2i, visionflow::geometry::Size2f, visionflow::geometry::Size2i, visionflow::geometry::Vector2f, visionflow::geometry::Vector2i

Public Types

enum GeometryType#

Geometry enum value.

Values:

enumerator kRadian = 0#
enumerator kSize2f = 2#
enumerator kSize2i = 3#
enumerator kPoint2f = 4#
enumerator kPoint2i = 5#
enumerator kVector2f = 6#
enumerator kVector2i = 7#
enumerator kSegment2f = 8#
enumerator kSegment2i = 9#
enumerator kLine2f = 10#
enumerator kRay2f = 12#
enumerator kRay2i = 13#
enumerator kRing2f = 14#
enumerator kRing2i = 15#
enumerator kRect2f = 16#
enumerator kRect2i = 17#
enumerator kPolygon2f = 18#
enumerator kPolygon2i = 19#
enumerator kRotateRect2f = 20#
enumerator kRotateRect2i = 21#
enumerator kArc2f = 22#
enumerator kCircle2f = 24#
enumerator kCircle2i = 25#
enumerator kLineString2f = 26#
enumerator kLineString2i = 27#
enumerator kMultiPoint2f = 28#
enumerator kMultiPoint2i = 29#
enumerator kMultiPolygon2f = 30#
enumerator kMultiPolygon2i = 31#
enumerator kEllipse2f = 32#
enumerator kMultiSegment2f = 34#

Public Functions

virtual IGeometry::GeometryType type() const = 0#

Enumerate value of geometry types.

const char *type_name() const#

Name of geometry types.

inline virtual bool is_surface() const#

Get if the geometry object is a surface.

Returns:

True if the geometry object is a surface. else false.

template<typename GeometryType>
inline const GeometryType &as() const#

Safe downcast to a specific geometry subtype (const version).

template<typename GeometryType>
inline GeometryType &as()#

Safe downcast to a specific geometry subtype (non-const version).

class ISurface : public visionflow::geometry::IGeometry#

The abstract base class for all surface geometry types.

Subclassed by visionflow::geometry::Circle2f, visionflow::geometry::Ellipse2f, visionflow::geometry::MultiPolygon2f, visionflow::geometry::Polygon2f, visionflow::geometry::Rect2f, visionflow::geometry::Ring2f, visionflow::geometry::RotateRect2f

Public Functions

virtual float area() const = 0#

Get the surface area.

virtual float perimeter() const = 0#

Surface perimeter.

virtual Point2f centroid() const = 0#

Get the centroid of the surface, the centroid may be different from the center in some surface.

virtual Rect2f bounding_box() const = 0#

Get the axises aligned bounding box.

virtual RotateRect2f min_area_box() const = 0#

Get the min area bounding box.

struct Radian : public visionflow::geometry::IGeometry#

Can easily get the degree of the radian conversion.

The direction from the positive direction of the x-axis to the positive direction of the y-axis is positive direction of the angle definition.

Public Functions

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Radian(float radian = 0)#

Construct a new Radian object.

bool operator==(const Radian &rhs) const#

Check if two radians are equal.

inline bool operator!=(const Radian &rhs) const#

Check if two radians are not equal.

Radian operator-() const#

Get the negation of this Radian.

inline Radian &operator-=(const Radian &rhs)#

Subtract assign another Radian.

inline Radian &operator+=(const Radian &rhs)#

Add assign another Radian.

inline Radian operator-(const Radian &rhs) const#

Binary subtraction operator.

inline Radian operator+(const Radian &rhs) const#

Binary addition operator.

Radian norm(float mod = visionflow::geometry::kPi * 2) const#

Normalize the radian into [0, mod).

Parameters:

mod – Divisor.

Returns:

Radian in [0, mod).

float degree() const#

Get the degree of the radian conversion.

Returns:

float degree.

Radian &from_degree(float degree)#

Set the radian of the degree conversion.

Parameters:

degree – Degree.

Returns:

Radian& reference to this object.

Vector2f unit_vector() const#

Get Radian correspond to unit vector.

The direction of the unit vector is the same as the direction of the Radian, i.e. from the positive direction of the x-axis to the positive direction of the y-axis is positive direction of the angle definition.

Returns:

Vector2f unit vector in the same direction as the Radian.

Public Members

float radian#

Radian data.

Public Static Functions

static Radian FromDegree(float degree)#

Construct radian from degree.

struct Vector2f : public visionflow::geometry::IGeometry#

A floating-point vector with size and direction from the origin point (0, 0).

Public Types

using Elem = float#

Element type.

using Point = Point2f#

Vector corresponding to a floating-point number type.

Public Functions

Vector2f() = default#

Default constructor.

Vector2f(const Elem &x, const Elem &y)#

Constructor to set two values.

explicit Vector2f(const Point &point)#

Constructor to set a Point.

explicit Vector2f(const Vector2i &vector)#

Construct a new vector with number type conversion.

bool operator==(const Vector2f &rhs) const#

Equality comparison.

Vector2f operator-() const#

Unary negation (inverse direction).

Vector2f operator+(const Vector2f &rhs) const#

Vector addition.

Vector2f operator-(const Vector2f &rhs) const#

Vector subtraction.

Vector2f operator*(Elem rhs) const#

Scalar multiplication.

Vector2f operator/(Elem rhs) const#

Scalar division.

Elem operator*(const Vector2f &rhs) const#

Vector product.

Vector2f &operator+=(const Vector2f &rhs)#

Add and assign.

Vector2f &operator-=(const Vector2f &rhs)#

Subtract and assign.

Vector2f &operator*=(Elem rhs)#

Multiply by scalar and assign.

Vector2f &operator/=(Elem rhs)#

Divide by scalar and assign.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Radian azimuth() const#

Azimuth of a vector.

Returns:

Radian The radian of the rotation of the vector from the positive direction of the x-axis to the positive direction of the y-axis(±π).

float length() const#

Modulus of a vector.

Returns:

float Modulus length.

Public Members

Elem x = 0#

x coordinate.

Elem y = 0#

y coordinate.

struct Vector2i : public visionflow::geometry::IGeometry#

Integer vector with size and direction from the origin (0,0).

Public Types

using Elem = int32_t#

Element type.

using Point = Point2i#

Vector corresponding to an integer point of the same number type.

Public Functions

Vector2i() = default#

Default constructor.

Vector2i(const Elem &x, const Elem &y)#

Constructor to set two values.

explicit Vector2i(const Point2i &point)#

Constructor to set a Point.

bool operator==(const Vector2i &rhs) const#

Equality comparison.

Vector2i operator-() const#

Unary negation (inverse direction).

Vector2i operator+(const Vector2i &rhs) const#

Vector addition.

Vector2i operator-(const Vector2i &rhs) const#

Vector subtraction.

Vector2i operator*(Elem rhs) const#

Scalar multiplication.

Vector2i operator/(Elem rhs) const#

Scalar division.

Elem operator*(const Vector2i &rhs) const#

Vector product.

Vector2i &operator+=(const Vector2i &rhs)#

Add and assign.

Vector2i &operator-=(const Vector2i &rhs)#

Subtract and assign.

Vector2i &operator*=(Elem rhs)#

Multiply by scalar and assign.

Vector2i &operator/=(Elem rhs)#

Divide by scalar and assign.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Radian azimuth() const#

Azimuth of a vector.

Returns:

Radian The radian of the rotation of the vector from the positive direction of the x-axis to the positive direction of the y-axis(±π).

float length() const#

Modulus of a vector.

Returns:

float Modulus length.

Public Members

Elem x = 0#

x coordinate.

Elem y = 0#

y coordinate.

struct Point2f : public visionflow::geometry::IGeometry#

Floating point coordinate points.

Public Types

using Elem = float#

Element type.

using Vector = Vector2f#

The vector of the same type corresponding to the point.

using Line = Line2f#

A line of the same type corresponding to a point.

Public Functions

Point2f() = default#

Default constructor.

explicit Point2f(const Point2i &point)#

Construct a new Point with number type conversion.

Point2f(Elem x, Elem y)#

Constructor to set two values.

explicit Point2f(const Vector &vector)#

Constructor to set a Vector.

bool operator==(const Point2f &rhs) const#

Equality comparison.

bool operator==(const Vector &rhs) const#

Numerical comparison with vectors of the same type.

Point2f operator+(const Vector &rhs) const#

Translation of points.

Point2f operator-(const Vector &rhs) const#

Translation of points.

Point2f operator*(Elem rhs) const#

Enlarge point coordinates.

Point2f operator/(Elem rhs) const#

Point coordinates reduced.

Point2f &operator+=(const Vector &rhs)#

Translation of points.

Point2f &operator-=(const Vector &rhs)#

Translation of points.

Point2f &operator*=(Elem rhs)#

Enlarge point coordinates.

Point2f &operator/=(Elem rhs)#

Point coordinates reduced.

Elem operator*(const Point2f &rhs) const#

Dot product.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Public Members

Elem x = 0#

x coordinate.

Elem y = 0#

y coordinate.

struct Point2i : public visionflow::geometry::IGeometry#

Integral point coordinate points.

Public Types

using Elem = int32_t#

Element type.

using Vector = Vector2i#

The vector of the same type corresponding to the point.

Public Functions

Point2i() = default#

Default constructor.

Point2i(Elem x, Elem y)#

Constructor to set two values.

explicit Point2i(const Vector &vector)#

Constructor to set a Vector.

bool operator==(const Point2i &rhs) const#

Equality comparison.

bool operator==(const Vector &rhs) const#

Numerical comparison with vectors of the same type.

Point2i operator+(const Vector &rhs) const#

Translation of points.

Point2i operator-(const Vector &rhs) const#

Translation of points.

Point2i operator*(Elem rhs) const#

Enlarge point coordinates.

Point2i operator/(Elem rhs) const#

Point coordinates reduced.

Point2i &operator+=(const Vector &rhs)#

Translation of points.

Point2i &operator-=(const Vector &rhs)#

Translation of points.

Point2i &operator*=(Elem rhs)#

Enlarge point coordinates.

Point2i &operator/=(Elem rhs)#

Point coordinates reduced.

Elem operator*(const Point2i &rhs) const#

Dot product.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Public Members

Elem x = 0#

x coordinate.

Elem y = 0#

y coordinate.

struct Segment2f : public visionflow::geometry::IGeometry#

Floating point line segments.

Public Types

using Point = Point2f#

Line segments corresponding to points of the same type.

using Vector = Vector2f#

Direction vectors of the same type corresponding to the line segment.

using Line = Line2f#

Line segment corresponding to a line of the same data type.

using Elem = Point2f::Elem#

Element type.

Public Functions

Segment2f() = default#

Default constructor.

explicit Segment2f(const Segment2i &segment)#

Construct a new Segment with number type conversion.

inline Segment2f(Point first, Point second)#

Constructor to set two Points.

Segment2f(const Point &point, const Vector &direction, float dis)#

Constructor to set Point, direction Vector and distance.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

float length() const#

Length of line segment.

Line in_line() const#

The line where the line segment is located.

Radian azimuth() const#

Azimuth of a line segment.

bool is_point() const#

Check if the Segment is equal to a Point.

Returns:

true if the ends of Segment are the same.

inline bool operator==(const Segment2f &rhs) const#

Determine if the line segments are the same.

inline bool operator!=(const Segment2f &rhs) const#

Determine if the line segments are different.

Public Members

Point first#

Starting point of the segment.

Point second#

Ending point of the segment.

struct Segment2i : public visionflow::geometry::IGeometry#

Integral line segments.

Public Types

using Point = Point2i#

Line segments corresponding to points of the same type.

using Vector = Vector2i#

Direction vectors of the same type corresponding to the line segment.

using Elem = Point2i::Elem#

Element type.

Public Functions

Segment2i() = default#

Default constructor.

inline Segment2i(Point first, Point second)#

Constructor to set two Points.

Segment2i(const Point &point, const Vector &direction, float dis)#

Constructor to set Point, direction Vector and distance.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

float length() const#

Length of line segment.

Line2f in_line() const#

The line where the line segment is located.

Radian azimuth() const#

Azimuth of a line segment.

bool is_point() const#

Check if the Segment is equal to a Point.

Returns:

true if the ends of Segment are the same.

inline bool operator==(const Segment2i &rhs) const#

Determine if the line segments are the same.

inline bool operator!=(const Segment2i &rhs) const#

Determine if the line segments are different.

Public Members

Point first#

Starting point of the segment.

Point second#

Ending point of the segment.

struct Line2f : public visionflow::geometry::IGeometry#

Floating-point 2D line.

A line represents an infinite straight path in 2D space. It can be constructed from coefficients of the standard line equation (ax + by + c = 0), two distinct points on the line, a point with a direction vector, or a segment that lies along the line.

Public Types

using Point = Point2f#

Point type for positions on the line.

using Segment = Segment2f#

Segment type for defining a line from endpoints.

using Vector = Vector2f#

Direction vector type for the line.

using Elem = float#

Element type.

Public Functions

Line2f() = default#

Default constructor.

Line2f(Elem a, Elem b, Elem c)#

Constructor to set ax + by + c = 0.

\[ ax + by + c = 0 \]

Line2f(const Point &first, const Point &second)#

Constructor to set two Points.

Line2f(const Point &point, const Vector &direction)#

Constructor to set Point and direction Vector.

explicit Line2f(const Segment &segment)#

Constructor to set a Segment.

explicit Line2f(const Segment2i &segment)#

Constructor to set a Segment.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Point passing_point() const#

Get a representative point on the line.

The returned point is guaranteed to lie on the line. If the line crosses the y-axis, the intersection with the y-axis is preferred; otherwise the intersection with the x-axis is returned.

Returns:

A point on the line.

Radian azimuth() const#

Get the orientation angle (azimuth) of the line direction.

Returns:

A Radian representing the angle of the line’s direction vector measured from the positive x-axis toward the positive y-axis.

Point intersection_by_y(Elem value) const#

Intersection of a line parallel to the x-axis.

  • If there is no intersection it will throw an exception.

  • If there is a complete overlap it will return Point(0, value).

Parameters:

value – The line y = value.

Throws:

visionflow::excepts::InvalidArgument – If Lines have no intersection.

Returns:

Point the intersection.

Point intersection_by_x(Elem value) const#

Intersection of a line parallel to the y-axis.

  • If there is no intersection it will return an exception.

  • If there is a complete overlap it will return Point(value, 0).

Parameters:

value – The line x = value.

Throws:

visionflow::excepts::InvalidArgument – If Lines have no intersection.

Returns:

Point the intersection.

Public Members

Elem a = 0#

Coefficient of x in the standard line equation.

Elem b = 1#

Coefficient of y in the standard line equation.

Elem c = 0#

Constant term in the standard line equation.

struct Ray2f : public visionflow::geometry::IGeometry#

Floating-point ray.

Public Types

using Point = Point2f#

Point type corresponding to the ray.

using Vector = Vector2f#

Direction vector type for the ray.

using Line = Line2f#

Line type corresponding to the infinite supporting line.

Public Functions

Ray2f(Point start, Vector direction)#

Constructor to set Point and direction Vector.

Ray2f(const Point &first, const Point &second)#

Constructor to set two Points.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Radian azimuth() const#

Get the azimuth (orientation angle) of the ray.

Line in_line() const#

Get the infinite line containing this ray.

Public Members

Point start#

The starting point of the ray.

Vector direction#

The direction vector of the ray (not necessarily normalized).

struct Ray2i : public visionflow::geometry::IGeometry#

Integral ray.

Public Types

using Point = Point2i#

Point type corresponding to the ray.

using Vector = Vector2i#

Direction vector type for the ray.

Public Functions

Ray2i(Point start, Vector direction)#

Constructor to set Point and direction Vector.

Ray2i(const Point &first, const Point &second)#

Constructor to set two Points.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Radian azimuth() const#

Get the azimuth (orientation angle) of the ray.

Line2f in_line() const#

Get the infinite line containing this ray.

Public Members

Point start#

The starting point of the ray.

Vector direction#

The direction vector of the ray (not necessarily normalized).

struct LineString2f : public visionflow::geometry::IGeometry#

Floating-point polyline.

A polyline is a list of points (std::vector), where line segments are drawn between consecutive points.

Note

A polyline can be self-intersecting, which may cause errors in some algorithms. It can be checked for self-intersections using is_simple().

Public Types

using Point = Point2f#

The corresponding point type for the geometry.

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

LineString2f() = default#

Default constructor, creating an empty LineString.

explicit LineString2f(const LineString2i &line_string)#

Construct a new LineString with number type conversion.

LineString2f(Point first, Point second)#

Constructor to set two Points.

float length() const#

Sum of lengths of line segments.

LineString2f(std::initializer_list<Point> init)#

Constructor taking std::initializer_list, filling the LineString.

explicit LineString2f(std::vector<Point> elements)#

Construct a new LineString with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Point> ilist)#

Replace the contents with new contents.

Point &at(size_t index)#

Get a reference to a point at the given index.

const Point &at(size_t index) const#

Get a const reference to a point at the given index.

Point &operator[](size_t index)#

Get a reference to a point at the given index.

const Point &operator[](size_t index) const#

Get a const reference to a point at the given index.

Point &front()#

Returns a reference to the first element.

const Point &front() const#

Returns a reference to the first element.

Point &back()#

Returns a reference to the last element.

const Point &back() const#

Returns a reference to the last element.

Point *data() noexcept#

Pointer to the underlying element storage.

const Point *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Point>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Point>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Point>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Point>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Point>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Point>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the LineString is empty.

size_t size() const noexcept#

Get the number of points in the LineString.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the LineString.

void clear() noexcept#

Clear the LineString.

template<typename InputIter>
inline std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, const Point &value)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator erase(std::vector<Point>::iterator first, std::vector<Point>::iterator last)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator first, std::vector<Point>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Point &element)#

Append a point to the end of the LineString.

void push_back(Point &&element)#

Append a point to the end of the LineString.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a point at the end of the LineString.

void pop_back()#

Remove the last point from the LineString.

void resize(size_t new_size)#

Resize the LineString to a new size.

bool operator==(const LineString2f &other) const#

Check that they have the same number of elements and that each element is in the same position.

Point get(size_t index) const#

Get a point at the given index.

void set(size_t index, const Point &element)#

Set a point at the given index.

void erase(size_t index)#

Erase a point at the given index.

operator const std::vector<Point>&() const#

Convert to std::vector.

operator std::vector<Point>&()#

Convert to std::vector.

std::vector<Point>::iterator erase(std::vector<Point>::iterator pos)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Point> points#

Points of the LineString.

struct LineString2i : public visionflow::geometry::IGeometry#

Integral polyline.

A polyline is a list of points (std::vector), where line segments are drawn between consecutive points.

Note

A polyline can be self-intersecting, which may cause errors in some algorithms. It can be checked for self-intersections using is_simple().

Public Types

using Point = Point2i#

The corresponding point type for the geometry.

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

LineString2i() = default#

Default constructor, creating an empty LineString.

LineString2i(Point first, Point second)#

Constructor to set two Points.

float length() const#

Sum of lengths of line segments.

LineString2i(std::initializer_list<Point> init)#

Constructor taking std::initializer_list, filling the LineString.

explicit LineString2i(std::vector<Point> elements)#

Construct a new LineString with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Point> ilist)#

Replace the contents with new contents.

Point &at(size_t index)#

Get a reference to a point at the given index.

const Point &at(size_t index) const#

Get a const reference to a point at the given index.

Point &operator[](size_t index)#

Get a reference to a point at the given index.

const Point &operator[](size_t index) const#

Get a const reference to a point at the given index.

Point &front()#

Returns a reference to the first element.

const Point &front() const#

Returns a reference to the first element.

Point &back()#

Returns a reference to the last element.

const Point &back() const#

Returns a reference to the last element.

Point *data() noexcept#

Pointer to the underlying element storage.

const Point *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Point>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Point>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Point>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Point>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Point>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Point>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the LineString is empty.

size_t size() const noexcept#

Get the number of points in the LineString.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the LineString.

void clear() noexcept#

Clear the LineString.

template<typename InputIter>
inline std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, const Point &value)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator erase(std::vector<Point>::iterator first, std::vector<Point>::iterator last)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator first, std::vector<Point>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Point &element)#

Append a point to the end of the LineString.

void push_back(Point &&element)#

Append a point to the end of the LineString.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a point at the end of the LineString.

void pop_back()#

Remove the last point from the LineString.

void resize(size_t new_size)#

Resize the LineString to a new size.

bool operator==(const LineString2i &other) const#

Check that they have the same number of elements and that each element is in the same position.

Point get(size_t index) const#

Get a point at the given index.

void set(size_t index, const Point &element)#

Set a point at the given index.

void erase(size_t index)#

Erase a point at the given index.

operator const std::vector<Point>&() const#

Convert to std::vector.

operator std::vector<Point>&()#

Convert to std::vector.

std::vector<Point>::iterator erase(std::vector<Point>::iterator pos)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Point> points#

Points of the LineString.

struct Ring2f : public visionflow::geometry::ISurface#

Floating-point ring.

  • A ring is a closed curve that does not intersect itself, i.e., it forms a polygon without holes.

  • The points on the ring should be described in a counter-clockwise direction from the positive x-axis to the positive y-axis, with the first point and the last point being different.

Public Types

using Point = Point2f#

The corresponding point type for the geometry.

using LineString = LineString2f#

The corresponding polyline type for the geometry. disjoint().

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

Ring2f() = default#

Default constructor, creating an empty Ring.

virtual float area() const override#

Get the surface area.

virtual float perimeter() const override#

Surface perimeter.

explicit Ring2f(const Ring2i &rhs)#

Construct a new Ring with number type conversion.

virtual Point2f centroid() const override#

Get the centroid of the surface, the centroid may be different from the center in some surface.

virtual Rect2f bounding_box() const override#

Get the axises aligned bounding box.

virtual RotateRect2f min_area_box() const override#

Get the min area bounding box.

inline virtual bool is_surface() const final#

Get if the geometry object is a surface.

Ring2f(std::initializer_list<Point> init)#

Constructor taking std::initializer_list, filling the Ring.

explicit Ring2f(std::vector<Point> elements)#

Construct a new Ring with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Point> ilist)#

Replace the contents with new contents.

Point &at(size_t index)#

Get a reference to a point at the given index.

const Point &at(size_t index) const#

Get a const reference to a point at the given index.

Point &operator[](size_t index)#

Get a reference to a point at the given index.

const Point &operator[](size_t index) const#

Get a const reference to a point at the given index.

Point &front()#

Returns a reference to the first element.

const Point &front() const#

Returns a reference to the first element.

Point &back()#

Returns a reference to the last element.

const Point &back() const#

Returns a reference to the last element.

Point *data() noexcept#

Pointer to the underlying element storage.

const Point *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Point>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Point>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Point>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Point>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Point>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Point>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the Ring is empty.

size_t size() const noexcept#

Get the number of points in the Ring.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the Ring.

void clear() noexcept#

Clear the Ring.

template<typename InputIter>
inline std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, const Point &value)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator erase(std::vector<Point>::iterator first, std::vector<Point>::iterator last)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator first, std::vector<Point>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Point &element)#

Append a point to the end of the Ring.

void push_back(Point &&element)#

Append a point to the end of the Ring.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a point at the end of the Ring.

void pop_back()#

Remove the last point from the Ring.

void resize(size_t new_size)#

Resize the Ring to a new size.

bool operator==(const Ring2f &other) const#

Check that they have the same number of elements and that each element is in the same position.

Point get(size_t index) const#

Get a point at the given index.

void set(size_t index, const Point &element)#

Set a point at the given index.

void erase(size_t index)#

Erase a point at the given index.

operator const std::vector<Point>&() const#

Convert to std::vector.

operator std::vector<Point>&()#

Convert to std::vector.

std::vector<Point>::iterator erase(std::vector<Point>::iterator pos)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Point> points#

Points of the Ring.

struct Ring2i : public visionflow::geometry::IGeometry#

Integral ring.

  • A ring is a closed curve that does not intersect itself, i.e., it forms a polygon without holes.

  • The points on the ring should be described in a counter-clockwise direction from the positive x-axis to the positive y-axis, with the first point and the last point being different.

Public Types

using Point = Point2i#

The corresponding point type for the geometry.

using LineString = LineString2i#

The corresponding polyline type for the geometry. disjoint().

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

Ring2i() = default#

Default constructor, creating an empty Ring.

float area() const#

Get the surface area.

float perimeter() const#

Surface perimeter.

Ring2i(std::initializer_list<Point> init)#

Constructor taking std::initializer_list, filling the Ring.

explicit Ring2i(std::vector<Point> elements)#

Construct a new Ring with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Point> ilist)#

Replace the contents with new contents.

Point &at(size_t index)#

Get a reference to a point at the given index.

const Point &at(size_t index) const#

Get a const reference to a point at the given index.

Point &operator[](size_t index)#

Get a reference to a point at the given index.

const Point &operator[](size_t index) const#

Get a const reference to a point at the given index.

Point &front()#

Returns a reference to the first element.

const Point &front() const#

Returns a reference to the first element.

Point &back()#

Returns a reference to the last element.

const Point &back() const#

Returns a reference to the last element.

Point *data() noexcept#

Pointer to the underlying element storage.

const Point *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Point>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Point>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Point>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Point>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Point>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Point>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the Ring is empty.

size_t size() const noexcept#

Get the number of points in the Ring.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the Ring.

void clear() noexcept#

Clear the Ring.

template<typename InputIter>
inline std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, const Point &value)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator erase(std::vector<Point>::iterator first, std::vector<Point>::iterator last)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator first, std::vector<Point>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Point &element)#

Append a point to the end of the Ring.

void push_back(Point &&element)#

Append a point to the end of the Ring.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a point at the end of the Ring.

void pop_back()#

Remove the last point from the Ring.

void resize(size_t new_size)#

Resize the Ring to a new size.

bool operator==(const Ring2i &other) const#

Check that they have the same number of elements and that each element is in the same position.

Point get(size_t index) const#

Get a point at the given index.

void set(size_t index, const Point &element)#

Set a point at the given index.

void erase(size_t index)#

Erase a point at the given index.

operator const std::vector<Point>&() const#

Convert to std::vector.

operator std::vector<Point>&()#

Convert to std::vector.

std::vector<Point>::iterator erase(std::vector<Point>::iterator pos)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Point> points#

Points of the Ring.

struct Size2f : public visionflow::geometry::IGeometry#

Specify rect or image size.

Public Types

using Elem = float#

Element type.

Public Functions

Size2f() = default#

Default constructor.

Size2f(const Size2i &size)#

Construct from Size2i.

Size2f(Elem w, Elem h)#

Construct a new Size 2f object.

Parameters:
  • w – Width (cols).

  • h – Height (rows).

bool operator==(const Size2f &rhs) const#

Equality comparison.

inline bool operator!=(const Size2f &rhs) const#

Inequality comparison.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

inline Size2f operator*(Elem ratio) const#

Multiply size by a scalar ratio.

inline Size2f operator/(Elem ratio) const#

Divide size by a scalar ratio.

inline Size2f &operator*=(Elem ratio)#

Multiply and assign.

inline Size2f &operator/=(Elem ratio)#

Divide and assign.

inline Elem area() const#

Area size.

Public Members

Elem w = 0.0#

Width (cols).

Elem h = 0.0#

Height (rows).

struct Size2i : public visionflow::geometry::IGeometry#

Specify rect or image size.

Public Types

using Elem = uint32_t#

Element type.

Public Functions

Size2i() = default#

Default constructor.

Size2i(Elem w, Elem h)#

Construct a new Size2i object.

Parameters:
  • w – Width (cols).

  • h – Height (rows).

bool operator==(const Size2i &rhs) const#

Equality comparison.

inline bool operator!=(const Size2i &rhs) const#

Inequality comparison.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

inline Size2i operator*(Elem ratio) const#

Multiply size by a scalar ratio.

inline Size2i operator/(Elem ratio) const#

Divide size by a scalar ratio.

inline Size2i &operator*=(Elem ratio)#

Multiply and assign.

inline Size2i &operator/=(Elem ratio)#

Divide and assign.

inline Elem area() const#

Area size.

Public Members

Elem w = 0.0#

Width (cols).

Elem h = 0.0#

Height (rows).

struct Rect2f : public visionflow::geometry::ISurface#

Floating-point axis-aligned rectangle.

A rectangle is a parallelogram with one right angle and sides parallel to the coordinate axes. It is defined by its minimum corner (min_corner) and size (size).

Public Types

using Point = Point2f#

Point type corresponding to the rectangle.

using Size = Size2f#

The corresponding size of the same type for the rectangle.

using Elem = float#

Element type.

using LineString = LineString2f#

Line type representing the edges of the rectangle.

using Ring = Ring2f#

Ring type representing the rectangle boundary, see convert().

Public Functions

Rect2f() = default#

Default constructor.

explicit Rect2f(const Rect2i &rect)#

Construct a new Rect with number type conversion.

Rect2f(Point min_corner, Size size)#

Construct Rect with min corner point and size.

Rect2f(Point min_corner, const Elem &w, const Elem &h)#

Construct a rectangle from its minimum corner and explicit width and height.

Rect2f(const Point &first, const Point &second)#

Construct a rectangle from two diagonal corner points.

bool operator==(const Rect2f &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Point xmin_ymin() const#

Get the vertex with the minimum x and y values (lower-left corner). Same as min_corner.

Point xmax_ymin() const#

Get the vertex with maximum x and minimum y values (lower-right corner).

Point xmax_ymax() const#

Get the vertex with maximum x and y values (upper-right corner).

Point xmin_ymax() const#

Get the vertex with minimum x and maximum y values (upper-left corner).

virtual float area() const override#

Get the surface area.

virtual float perimeter() const override#

Surface perimeter.

virtual Point2f centroid() const override#

Get the centroid of the surface, the centroid may be different from the center in some surface.

inline virtual Rect2f bounding_box() const override#

Get the axises aligned bounding box.

virtual RotateRect2f min_area_box() const override#

Get the min area bounding box.

float long_side() const#

Convert the long side length of the rectangle.

float short_side() const#

Convert the short side length of the rectangle.

Ring to_ring() const#

Convert rectangle to ring.

inline virtual bool is_surface() const final#

Get if the geometry object is a surface.

Public Members

Point min_corner#

Lower-left corner (minimum x and y).

Size size#

Rectangle size (width and height).

struct Rect2i : public visionflow::geometry::IGeometry#

Integral axis-aligned rectangle.

A rectangle is a parallelogram with one right angle and sides parallel to the coordinate axes. It is defined by its minimum corner (min_corner) and size (size).

Public Types

using Point = Point2i#

Point type corresponding to the rectangle.

using Size = Size2i#

The corresponding size of the same type for the rectangle.

using Elem = int32_t#

Element type.

using LineString = LineString2i#

Line type representing the edges of the rectangle.

using Ring = Ring2i#

Ring type representing the rectangle boundary, see convert().

Public Functions

Rect2i() = default#

Default constructor.

Rect2i(Point min_corner, Size size)#

Construct Rect with min corner point and size.

Rect2i(Point min_corner, const Elem &w, const Elem &h)#

Construct a rectangle from its minimum corner and explicit width and height.

Rect2i(const Point &first, const Point &second)#

Construct a rectangle from two diagonal corner points.

bool operator==(const Rect2i &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Point xmin_ymin() const#

Get the vertex with the minimum x and y values (lower-left corner). Same as min_corner.

Point xmax_ymin() const#

Get the vertex with maximum x and minimum y values (lower-right corner).

Point xmax_ymax() const#

Get the vertex with maximum x and y values (upper-right corner).

Point xmin_ymax() const#

Get the vertex with minimum x and maximum y values (upper-left corner).

Elem area() const#

Rectangle area.

Elem perimeter() const#

Rectangle perimeter.

Elem long_side() const#

Convert the long side length of the rectangle.

Elem short_side() const#

Convert the short side length of the rectangle.

Ring to_ring() const#

Convert rectangle to ring.

Public Members

Point min_corner#

Lower-left corner (minimum x and y).

Size size#

Rectangle size (width and height).

struct Polygon2f : public visionflow::geometry::ISurface#

Floating-point polygon surface.

  • A polygon is a planar surface defined by one exterior boundary (outer ring) and zero or more interior boundaries (inner rings or holes). Inner rings represent holes and must have opposite winding direction from the outer ring.

  • Point sequences for each ring should be “open” (i.e., the first and last points are not repeated). The direction from the positive x-axis toward the positive y-axis defines the positive orientation of an angle used for ring traversal and related computations.

Public Types

using Ring = Ring2f#

Ring type representing a closed boundary.

using RingList = std::vector<Ring>#

Container type for inner rings (holes).

using Point = Ring2f::Point#

Point type used for polygon vertices.

Public Functions

Polygon2f() = default#

Default constructor, creating an empty Polygon.

explicit Polygon2f(const Polygon2i &polygon)#

Construct a new Polygon with number type conversion.

Polygon2f(std::initializer_list<Ring> init)#

Constructor taking std::initializer_list, filling the Polygon.

explicit Polygon2f(std::vector<Ring> elements)#

Construct a new Polygon with std::vector.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

virtual float area() const override#

Get the surface area.

Warning

If the inner ring is described incorrectly, such as being in the same direction as the outer, the area calculation will duplicate the area of the inner ring. You can use correct() to correct the geometry and obtain the correct expected result. Even when the inner ring is tangent to each other or tangent to the outer ring, the correct polygon area can still be obtained.

virtual float perimeter() const override#

Surface perimeter.

Warning

If the inner rings are tangent to each other or tangent to the outer rings, the tangent side lengths are repeated when calculating the circumference.

virtual Point2f centroid() const override#

Get the centroid of the surface, the centroid may be different from the center in some surface.

virtual Rect2f bounding_box() const override#

Get the axises aligned bounding box.

virtual RotateRect2f min_area_box() const override#

Get the min area bounding box.

inline virtual bool is_surface() const final#

Get if the geometry object is a surface.

bool operator==(const Polygon2f &other) const#

Check that they have the same number of elements and that each element is in the same position.

Public Members

Ring outer#

The outer boundary ring, described counterclockwise.

RingList inners#

Zero or more inner rings (holes), each described in the opposite direction to the outer ring.

struct Polygon2i : public visionflow::geometry::IGeometry#

Integral polygon surface.

  • A polygon is a planar surface defined by one exterior boundary (outer ring) and zero or more interior boundaries (inner rings or holes). Inner rings represent holes and must have opposite winding direction from the outer ring.

  • Point sequences for each ring should be “open” (i.e., the first and last points are not repeated). The direction from the positive x-axis toward the positive y-axis defines the positive orientation of an angle used for ring traversal and related computations.

Public Types

using Ring = Ring2i#

Ring type representing a closed boundary.

using RingList = std::vector<Ring>#

Container type for inner rings (holes).

using Point = Ring2i::Point#

Point type used for polygon vertices.

Public Functions

Polygon2i() = default#

Default constructor, creating an empty Polygon.

Polygon2i(std::initializer_list<Ring> init)#

Constructor taking std::initializer_list, filling the Polygon.

explicit Polygon2i(std::vector<Ring> elements)#

Construct a new Polygon with std::vector.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

float area() const#

Get the surface area.

Warning

If the inner ring is described incorrectly, such as being in the same direction as the outer, the area calculation will duplicate the area of the inner ring. You can use correct() to correct the geometry and obtain the correct expected result. Even when the inner ring is tangent to each other or tangent to the outer ring, the correct polygon area can still be obtained.

float perimeter() const#

Surface perimeter.

Warning

If the inner rings are tangent to each other or tangent to the outer rings, the tangent side lengths are repeated when calculating the circumference.

bool operator==(const Polygon2i &other) const#

Check that they have the same number of elements and that each element is in the same position.

Public Members

Ring outer#

The outer boundary ring, described counterclockwise.

RingList inners#

Zero or more inner rings (holes), each described in the opposite direction to the outer ring.

struct RotateRect2f : public visionflow::geometry::ISurface#

Floating-point rotated rectangle.

  • A rotated rectangle is a parallelogram with one right angle that is not necessarily aligned with the coordinate axes. It is defined by its center point (center), size (size), and rotation angle (radian).

  • Multiple rotated rectangles with the same coverage area but different orientation angles are considered distinct.

Public Types

using Point = Point2f#

Point type corresponding to the rotated rectangle.

using Size = Size2f#

Size of the rotated rectangle.

The width w corresponds to the edge along the rotation direction, while the height h is perpendicular to that direction.

using Ring = Ring2f#

Ring type corresponding to this rotated rectangle, see convert().

Public Functions

RotateRect2f() = default#

Default constructor.

RotateRect2f(Point center, Size size, Radian radian = {})#

Construct a rotated rectangle from its center, size, and rotation angle.

bool operator==(const RotateRect2f &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

inline virtual float area() const override#

Get the surface area.

inline virtual float perimeter() const override#

Surface perimeter.

inline virtual Point2f centroid() const override#

Get the centroid of the surface, the centroid may be different from the center in some surface.

virtual Rect2f bounding_box() const override#

Get the axises aligned bounding box.

inline virtual RotateRect2f min_area_box() const override#

Get the min area bounding box.

float long_side() const#

Convert the long side length of the rectangle.

float short_side() const#

Convert the short side length of the rectangle.

Ring to_ring() const#

Convert this rotated rectangle into a ring.

The returned ring contains the four corner points of the rectangle, computed by rotating the axis-aligned corner offsets about the center by the stored radian angle. The four corners are generated from the original offsets: ( +w/2, +h/2 ), ( -w/2, +h/2 ), ( -w/2, -h/2 ), ( +w/2, -h/2 ). After rotation, these become the actual vertex positions around center.

RotateRect2f norm() const#

Normalize the radian into [0, kPi / 2).

Width and height will be exchanged due to angle change.

Returns:

RotateRect2f with radian in [0, kPi / 2).

RotateRect2f norm_compatible_opencv() const#

Normalize the radian into (0, kPi / 2] like opencv.

Width and height will be exchanged due to angle change.

Returns:

RotateRect2f with radian in (0, kPi / 2].

inline virtual bool is_surface() const final#

Get if the geometry object is a surface.

Returns:

Always returns true.

Public Members

Point center#

Center point of the rectangle.

Size size#

Size (width and height) of the rectangle.

Radian radian#

Rotation angle in radians.

struct RotateRect2i : public visionflow::geometry::IGeometry#

Integer rotated rectangle.

  • A rotated rectangle is a parallelogram with one right angle that is not necessarily aligned with the coordinate axes. It is defined by its center point (center), size (size), and rotation angle (radian).

  • Multiple rotated rectangles with the same coverage area but different orientation angles are considered distinct.

Public Types

using Point = Point2i#

Point type corresponding to the rotated rectangle.

using Size = Size2i#

Size of the rotated rectangle.

The width w corresponds to the edge along the rotation direction, while the height h is perpendicular to that direction.

using Ring = Ring2i#

Ring type corresponding to this rotated rectangle, see convert().

Public Functions

RotateRect2i() = default#

Default constructor.

RotateRect2i(Point center, Size size, Radian radian = {})#

Construct a rotated rectangle from its center, size, and rotation angle.

bool operator==(const RotateRect2i &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

inline uint32_t area() const#

Get the surface area.

inline uint32_t perimeter() const#

Surface perimeter.

uint32_t long_side() const#

Convert the long side length of the rectangle.

uint32_t short_side() const#

Convert the short side length of the rectangle.

Ring to_ring() const#

Convert this rotated rectangle into a ring.

The returned ring contains the four corner points of the rectangle, computed by rotating the axis-aligned corner offsets about the center by the stored radian angle. The four corners are generated from the original offsets: ( +w/2, +h/2 ), ( -w/2, +h/2 ), ( -w/2, -h/2 ), ( +w/2, -h/2 ). After rotation, these become the actual vertex positions around center.

Rect2i bounding_box() const#

Get the bounding box.

Public Members

Point center#

Center point of the rectangle.

Size size#

Size (width and height) of the rectangle.

Radian radian#

Rotation angle in radians.

struct Ellipse2f : public visionflow::geometry::ISurface#

Float type ellipse.

  • An ellipse is a plane curve surrounding two focal points, such that for all points on the curve, the sum of the two distances to the focal points is a constant.

  • An ellipse is defined by its centre point, the axis of the major and minor semi-axes, and the rotation angle radian around the centre point.

  • Multiple ellipses with the same coverage, but rotation angle at different angles, are essentially different.

Public Types

using Point = Point2f#

The ellipse corresponding to a point of the same type.

using Axis = Size2f#

Type of ellipse consisting of the major and minor semi-axes.

using Focus = Segment2f#

Type consisting of the left and right focal points on the x-axis under the equation of a standard ellipse.

using Rect = Rect2f#

The ellipse corresponding to a rectangle of the same type.

Public Functions

Ellipse2f() = default#

Default constructor.

Ellipse2f(Point center, float major_semi_axis, float minor_semi_axis, Radian radian = {})#

Constructor to set centre point, major and minor semi-axes and rotation angle.

Require major_semi_axis >= minor_semi_axis, otherwise swap major_semi_axis and minor_semi_axis and add kPi * 0.5 to radian. An exception will be thrown if major_semi_axis or minor_semi_axis is not greater than 0.

Parameters:
  • center – Centre point.

  • major_semi_axis – Major semi-axis.

  • minor_semi_axis – Minor semi-axis.

  • radian – Rotation angle around the centre point.

Throws:

visionflow::excepts::InvalidArgument – if major_semi_axis or minor_semi_axis is not greater than 0.

Ellipse2f(Point center, Axis axis, Radian radian = {})#

Constructor to set centre point, major and minor semi-axes and rotation angle.

Parameters:
  • center – Centre point.

  • axis – axis.w means major semi-axis, axis.h means minor semi-axis.

  • radian – Rotation angle around the centre point.

Ellipse2f(const Point &focus1, const Point &focus2, const Point &point)#

Construct an ellipse using two foci and a point on the curve.

Parameters:
  • focus1 – A focus of the ellipse.

  • focus2 – The other focus of the ellipse.

  • point – Any point on the ellipse satisfying the focal distance condition.

Ellipse2f(float a, float b, float d = 1, Point center = {})#

Construct an ellipse from a standard ellipse equation form.

\[ \frac{(x - center.x)^2}{a^2} + \frac{(y - center.y)^2}{b^2} = d (a \ge b \gt 0) \]

Parameters:
  • a – Major semi axis.

  • b – Minor semi axis.

  • d – Uniform scaling factor (default is 1).

  • center – The center point.

bool operator==(const Ellipse2f &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

Focus focus() const#

Compute the focal segment of the ellipse.

float ecc() const#

Compute the eccentricity of the ellipse.

inline virtual float area() const override#

The area of the ellipse.

virtual float perimeter() const override#

Get Ellipse perimeter(with Ramanujan approximation, See https://arxiv.org/pdf/math/0506384.pdf ).

inline virtual Point2f centroid() const override#

Get the centroid of the surface, the centroid may be different from the center in some surface.

virtual Rect2f bounding_box() const override#

Get the bounding box.

inline virtual RotateRect2f min_area_box() const override#

Get the min area bounding box.

inline virtual bool is_surface() const final#

Get if the geometry object is a surface.

Public Members

Point center#

Center of the ellipse.

Axis axis#

Semi-axes: .w is semi-major, .h is semi-minor.

Radian radian#

Rotation angle around the center.

struct Arc2f : public visionflow::geometry::IGeometry#

Floating-point circular arc segment.

An arc is a portion of the circumference of a circle defined by a centre, a radius, and two angular endpoints. For a given circle, the length of the arc between start_angle and end_angle is proportional to the central angle they subtend.

Public Types

using Point = Point2f#

Point type corresponding to arc points.

Public Functions

Arc2f() = default#

Default constructor.

Arc2f(Point center, float radius, Radian start_angle, Radian end_angle)#

Construct an arc from centre, radius and start/end angles.

bool operator==(const Arc2f &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

inline Radian angle() const#

Central angle.

inline float length() const#

Arc length.

Arc2f &norm(float mod = visionflow::geometry::kPi * 2)#

Normalized Arc radian.

Public Members

Point center#

The centre of the circle corresponding to the arc.

float radius = 0#

The radius of the circle corresponding to the arc.

Radian start_angle#

Arc start radian.

Radian end_angle#

Arc end radian.

struct Circle2f : public visionflow::geometry::ISurface#

Floating-point circle geometry.

Public Types

using Point = Point2f#

Point type corresponding to positions in the circle.

Public Functions

Circle2f() = default#

Default constructor.

Circle2f(Point center, float radius)#

Constructor to set center and radius.

bool operator==(const Circle2f &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

virtual float area() const override#

The area of the circle.

virtual float perimeter() const override#

Surface perimeter.

inline virtual Point2f centroid() const override#

Get the center of the circle.

inline virtual Rect2f bounding_box() const override#

Get the bounding box.

inline virtual RotateRect2f min_area_box() const override#

Get the min area bounding box.

inline virtual bool is_surface() const final#

Get if the geometry object is a surface.

Public Members

Point center#

Center point of the circle.

float radius = 0#

Radius of the circle (distance from center to boundary).

struct Circle2i : public visionflow::geometry::IGeometry#

Integer circle geometry.

Public Types

using Point = Point2i#

Point type corresponding to positions in the circle.

Public Functions

Circle2i() = default#

Default constructor.

Circle2i(Point center, float radius)#

Constructor to set center and radius.

bool operator==(const Circle2i &rhs) const#

Equality comparison operator.

virtual IGeometry::GeometryType type() const override#

Get enum representation of geometry type.

float area() const#

The area of the circle.

float perimeter() const#

Surface perimeter.

Public Members

Point center#

Center point of the circle.

float radius = 0#

Radius of the circle (distance from center to boundary).

struct MultiPoint2f : public visionflow::geometry::IGeometry#

Floating-point point set.

Warning

The algorithm implementation does not clear the existing data, leading to incorrect results.

Public Types

using Point = Point2f#

The corresponding point type for the geometry.

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

MultiPoint2f() = default#

Default constructor, no initialization.

explicit MultiPoint2f(const MultiPoint2i &rhs)#

Construct a new MultiPoint with number type conversion.

Rect2f bounding_box() const#

Get the bounding box.

MultiPoint2f(std::initializer_list<Point> init)#

Constructor taking std::initializer_list, filling the MultiPoint.

explicit MultiPoint2f(std::vector<Point> elements)#

Construct a new MultiPoint with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Point> ilist)#

Replace the contents with new contents.

Point &at(size_t index)#

Get a reference to a point at the given index.

const Point &at(size_t index) const#

Get a const reference to a point at the given index.

Point &operator[](size_t index)#

Get a reference to a point at the given index.

const Point &operator[](size_t index) const#

Get a const reference to a point at the given index.

Point &front()#

Returns a reference to the first element.

const Point &front() const#

Returns a reference to the first element.

Point &back()#

Returns a reference to the last element.

const Point &back() const#

Returns a reference to the last element.

Point *data() noexcept#

Pointer to the underlying element storage.

const Point *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Point>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Point>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Point>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Point>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Point>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Point>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the MultiPoint is empty.

size_t size() const noexcept#

Get the number of points in the MultiPoint.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the MultiPoint.

void clear() noexcept#

Clear the MultiPoint.

template<typename InputIter>
inline std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, const Point &value)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator erase(std::vector<Point>::iterator first, std::vector<Point>::iterator last)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator first, std::vector<Point>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Point &element)#

Append a point to the end of the MultiPoint.

void push_back(Point &&element)#

Append a point to the end of the MultiPoint.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a point at the end of the MultiPoint.

void pop_back()#

Remove the last point from the MultiPoint.

void resize(size_t new_size)#

Resize the MultiPoint to a new size.

bool operator==(const MultiPoint2f &other) const#

Check that they have the same number of elements and that each element is in the same position.

Point get(size_t index) const#

Get a point at the given index.

void set(size_t index, const Point &element)#

Set a point at the given index.

void erase(size_t index)#

Erase a point at the given index.

operator const std::vector<Point>&() const#

Convert to std::vector.

operator std::vector<Point>&()#

Convert to std::vector.

std::vector<Point>::iterator erase(std::vector<Point>::iterator pos)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Point> points#

Points of the MultiPoint.

struct MultiPoint2i : public visionflow::geometry::IGeometry#

Integral point set.

Warning

The algorithm implementation does not clear the existing data, leading to incorrect results.

Public Types

using Point = Point2i#

The corresponding point type for the geometry.

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

MultiPoint2i() = default#

Default constructor, no initialization.

MultiPoint2i(std::initializer_list<Point> init)#

Constructor taking std::initializer_list, filling the MultiPoint.

explicit MultiPoint2i(std::vector<Point> elements)#

Construct a new MultiPoint with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Point> ilist)#

Replace the contents with new contents.

Point &at(size_t index)#

Get a reference to a point at the given index.

const Point &at(size_t index) const#

Get a const reference to a point at the given index.

Point &operator[](size_t index)#

Get a reference to a point at the given index.

const Point &operator[](size_t index) const#

Get a const reference to a point at the given index.

Point &front()#

Returns a reference to the first element.

const Point &front() const#

Returns a reference to the first element.

Point &back()#

Returns a reference to the last element.

const Point &back() const#

Returns a reference to the last element.

Point *data() noexcept#

Pointer to the underlying element storage.

const Point *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Point>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Point>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Point>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Point>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Point>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Point>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Point>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the MultiPoint is empty.

size_t size() const noexcept#

Get the number of points in the MultiPoint.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the MultiPoint.

void clear() noexcept#

Clear the MultiPoint.

template<typename InputIter>
inline std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator insert(std::vector<Point>::const_iterator pos, const Point &value)#

Inserts elements at the specified location in the container.

std::vector<Point>::iterator erase(std::vector<Point>::iterator first, std::vector<Point>::iterator last)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator first, std::vector<Point>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Point &element)#

Append a point to the end of the MultiPoint.

void push_back(Point &&element)#

Append a point to the end of the MultiPoint.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a point at the end of the MultiPoint.

void pop_back()#

Remove the last point from the MultiPoint.

void resize(size_t new_size)#

Resize the MultiPoint to a new size.

bool operator==(const MultiPoint2i &other) const#

Check that they have the same number of elements and that each element is in the same position.

Point get(size_t index) const#

Get a point at the given index.

void set(size_t index, const Point &element)#

Set a point at the given index.

void erase(size_t index)#

Erase a point at the given index.

operator const std::vector<Point>&() const#

Convert to std::vector.

operator std::vector<Point>&()#

Convert to std::vector.

std::vector<Point>::iterator erase(std::vector<Point>::iterator pos)#

Erases the specified elements from the container.

std::vector<Point>::iterator erase(std::vector<Point>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Point> points#

Points of the MultiPoint.

struct MultiSegment2f : public visionflow::geometry::IGeometry#

Multiple line Segment2f.

Public Types

using Segment = Segment2f#

Type of Segment.

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

MultiSegment2f() = default#

Default constructor, no initialization.

MultiSegment2f(std::initializer_list<Segment> init)#

Constructor taking std::initializer_list, filling the MultiSegment.

explicit MultiSegment2f(std::vector<Segment> elements)#

Construct a new MultiSegment with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Segment> ilist)#

Replace the contents with new contents.

Segment &at(size_t index)#

Get a reference to a segment at the given index.

const Segment &at(size_t index) const#

Get a const reference to a segment at the given index.

Segment &operator[](size_t index)#

Get a reference to a segment at the given index.

const Segment &operator[](size_t index) const#

Get a const reference to a segment at the given index.

Segment &front()#

Returns a reference to the first element.

const Segment &front() const#

Returns a reference to the first element.

Segment &back()#

Returns a reference to the last element.

const Segment &back() const#

Returns a reference to the last element.

Segment *data() noexcept#

Pointer to the underlying element storage.

const Segment *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Segment>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Segment>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Segment>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Segment>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Segment>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Segment>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Segment>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Segment>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the MultiSegment is empty.

size_t size() const noexcept#

Get the number of segments in the MultiSegment.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the MultiSegment.

void clear() noexcept#

Clear the MultiSegment.

template<typename InputIter>
inline std::vector<Segment>::iterator insert(std::vector<Segment>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Segment>::iterator insert(std::vector<Segment>::const_iterator pos, const Segment &value)#

Inserts elements at the specified location in the container.

std::vector<Segment>::iterator erase(std::vector<Segment>::iterator first, std::vector<Segment>::iterator last)#

Erases the specified elements from the container.

std::vector<Segment>::iterator erase(std::vector<Segment>::const_iterator first, std::vector<Segment>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Segment &element)#

Append a segment to the end of the MultiSegment.

void push_back(Segment &&element)#

Append a segment to the end of the MultiSegment.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a segment at the end of the MultiSegment.

void pop_back()#

Remove the last segment from the MultiSegment.

void resize(size_t new_size)#

Resize the MultiSegment to a new size.

bool operator==(const MultiSegment2f &other) const#

Check that they have the same number of elements and that each element is in the same position.

Segment get(size_t index) const#

Get a segment at the given index.

void set(size_t index, const Segment &element)#

Set a segment at the given index.

void erase(size_t index)#

Erase a segment at the given index.

operator const std::vector<Segment>&() const#

Convert to std::vector.

operator std::vector<Segment>&()#

Convert to std::vector.

std::vector<Segment>::iterator erase(std::vector<Segment>::iterator pos)#

Erases the specified elements from the container.

std::vector<Segment>::iterator erase(std::vector<Segment>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Segment> segments#

Segments of the MultiSegment.

struct MultiPolygon2f : public visionflow::geometry::ISurface#

Floating-polygon multi-polygon.

Warning

The algorithm implementation does not clear the existing data, leading to incorrect results.

Public Types

using Polygon = Polygon2f#

The corresponding polygon type for the geometry.

using Point = Point2f#

The corresponding point type for the geometry.

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

MultiPolygon2f() = default#

Default constructor, no initialization.

explicit MultiPolygon2f(const MultiPolygon2i &rhs)#

Construct a new MultiPolygon with number type conversion.

virtual float area() const override#

The area of the circle.

virtual float perimeter() const override#

Surface perimeter.

virtual Point2f centroid() const override#

Get the center of the circle.

virtual Rect2f bounding_box() const override#

Get the bounding box.

virtual RotateRect2f min_area_box() const override#

Get the min area bounding box.

inline virtual bool is_surface() const final#

Get if the geometry object is a surface.

MultiPolygon2f(std::initializer_list<Polygon> init)#

Constructor taking std::initializer_list, filling the MultiPolygon.

explicit MultiPolygon2f(Polygon rhs)#

Construct a MultiPolygon with Polygon.

explicit MultiPolygon2f(std::vector<Polygon> elements)#

Construct a new MultiPolygon with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Polygon> ilist)#

Replace the contents with new contents.

Polygon &at(size_t index)#

Get a reference to a polygon at the given index.

const Polygon &at(size_t index) const#

Get a const reference to a polygon at the given index.

Polygon &operator[](size_t index)#

Get a reference to a polygon at the given index.

const Polygon &operator[](size_t index) const#

Get a const reference to a polygon at the given index.

Polygon &front()#

Returns a reference to the first element.

const Polygon &front() const#

Returns a reference to the first element.

Polygon &back()#

Returns a reference to the last element.

const Polygon &back() const#

Returns a reference to the last element.

Polygon *data() noexcept#

Pointer to the underlying element storage.

const Polygon *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Polygon>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Polygon>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Polygon>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Polygon>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Polygon>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Polygon>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Polygon>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Polygon>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the MultiPolygon is empty.

size_t size() const noexcept#

Get the number of polygons in the MultiPolygon.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the MultiPolygon.

void clear() noexcept#

Clear the MultiPolygon.

template<typename InputIter>
inline std::vector<Polygon>::iterator insert(std::vector<Polygon>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Polygon>::iterator insert(std::vector<Polygon>::const_iterator pos, const Polygon &value)#

Inserts elements at the specified location in the container.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::iterator first, std::vector<Polygon>::iterator last)#

Erases the specified elements from the container.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::const_iterator first, std::vector<Polygon>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Polygon &element)#

Append a polygon to the end of the MultiPolygon.

void push_back(Polygon &&element)#

Append a polygon to the end of the MultiPolygon.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a polygon at the end of the MultiPolygon.

void pop_back()#

Remove the last polygon from the MultiPolygon.

void resize(size_t new_size)#

Resize the MultiPolygon to a new size.

bool operator==(const MultiPolygon2f &other) const#

Check that they have the same number of elements and that each element is in the same position.

Polygon get(size_t index) const#

Get a polygon at the given index.

void set(size_t index, const Polygon &element)#

Set a polygon at the given index.

void erase(size_t index)#

Erase a polygon at the given index.

operator const std::vector<Polygon>&() const#

Convert to std::vector.

operator std::vector<Polygon>&()#

Convert to std::vector.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::iterator pos)#

Erases the specified elements from the container.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Polygon> polygons#

Polygons of the MultiPolygon.

struct MultiPolygon2i : public visionflow::geometry::IGeometry#

Integral multi-polygon.

Warning

The algorithm implementation does not clear the existing data, leading to incorrect results.

Public Types

using Polygon = Polygon2i#

The corresponding polygon type for the geometry.

using Point = Point2i#

The corresponding point type for the geometry.

Public Functions

virtual IGeometry::GeometryType type() const override#

Enumerate value of geometry types.

MultiPolygon2i() = default#

Default constructor, no initialization.

MultiPolygon2i(std::initializer_list<Polygon> init)#

Constructor taking std::initializer_list, filling the MultiPolygon.

explicit MultiPolygon2i(std::vector<Polygon> elements)#

Construct a new MultiPolygon with std::vector.

template<typename InputIter>
inline void assign(InputIter first, InputIter last)#

Replace the contents with new contents.

void assign(std::initializer_list<Polygon> ilist)#

Replace the contents with new contents.

Polygon &at(size_t index)#

Get a reference to a polygon at the given index.

const Polygon &at(size_t index) const#

Get a const reference to a polygon at the given index.

Polygon &operator[](size_t index)#

Get a reference to a polygon at the given index.

const Polygon &operator[](size_t index) const#

Get a const reference to a polygon at the given index.

Polygon &front()#

Returns a reference to the first element.

const Polygon &front() const#

Returns a reference to the first element.

Polygon &back()#

Returns a reference to the last element.

const Polygon &back() const#

Returns a reference to the last element.

Polygon *data() noexcept#

Pointer to the underlying element storage.

const Polygon *data() const noexcept#

Pointer to the underlying element storage.

std::vector<Polygon>::iterator begin() noexcept#

Returns an iterator to the first element.

std::vector<Polygon>::const_iterator begin() const noexcept#

Returns an iterator to the first element.

std::vector<Polygon>::iterator end() noexcept#

Returns an iterator to the element following the last element.

std::vector<Polygon>::const_iterator end() const noexcept#

Returns an iterator to the element following the last element.

std::vector<Polygon>::reverse_iterator rbegin() noexcept#

Reverse iterator to the first element.

std::vector<Polygon>::const_reverse_iterator rbegin() const noexcept#

Reverse iterator to the first element.

std::vector<Polygon>::reverse_iterator rend() noexcept#

Reverse iterator to the element following the last element.

std::vector<Polygon>::const_reverse_iterator rend() const noexcept#

Reverse iterator to the element following the last element.

bool empty() const noexcept#

Check if the MultiPolygon is empty.

size_t size() const noexcept#

Get the number of polygons in the MultiPolygon.

void reserve(size_t new_capacity)#

Reserve storage.

size_t capacity() const noexcept#

Get the capacity of the MultiPolygon.

void clear() noexcept#

Clear the MultiPolygon.

template<typename InputIter>
inline std::vector<Polygon>::iterator insert(std::vector<Polygon>::const_iterator pos, InputIter first, InputIter last)#

Inserts elements at the specified location in the container.

std::vector<Polygon>::iterator insert(std::vector<Polygon>::const_iterator pos, const Polygon &value)#

Inserts elements at the specified location in the container.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::iterator first, std::vector<Polygon>::iterator last)#

Erases the specified elements from the container.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::const_iterator first, std::vector<Polygon>::const_iterator last)#

Erases the specified elements from the container.

void push_back(const Polygon &element)#

Append a polygon to the end of the MultiPolygon.

void push_back(Polygon &&element)#

Append a polygon to the end of the MultiPolygon.

template<typename ...Args>
inline void emplace_back(Args&&... args)#

Emplace a polygon at the end of the MultiPolygon.

void pop_back()#

Remove the last polygon from the MultiPolygon.

void resize(size_t new_size)#

Resize the MultiPolygon to a new size.

bool operator==(const MultiPolygon2i &other) const#

Check that they have the same number of elements and that each element is in the same position.

Polygon get(size_t index) const#

Get a polygon at the given index.

void set(size_t index, const Polygon &element)#

Set a polygon at the given index.

void erase(size_t index)#

Erase a polygon at the given index.

operator const std::vector<Polygon>&() const#

Convert to std::vector.

operator std::vector<Polygon>&()#

Convert to std::vector.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::iterator pos)#

Erases the specified elements from the container.

std::vector<Polygon>::iterator erase(std::vector<Polygon>::const_iterator pos)#

Erases the specified elements from the container.

Public Members

std::vector<Polygon> polygons#

Polygons of the MultiPolygon.

class Matrix3f#

3x3 float matrix.

Transformation matrix.

Public Functions

explicit Matrix3f(float diag = 1)#

Construct a 3*3 float matrix.

The value of the principal diagonal is diag, the rest are 0.

Parameters:

diag – The principal diagonal value. If rhs is 1(As default), it will construct a identity matrix.

Matrix3f(const std::vector<float> &row1, const std::vector<float> &row2, const std::vector<float> &row3)#

Construct a new Matrix3f object.

Parameters:
  • row1 – The first row of matrix.

  • row2 – The second row of matrix.

  • row3 – The third row of matrix.

Throws:

visionflow::excepts::InvalidArgument – If the input matrix size is not 3*3.

Matrix3f(float mat_0_0, float mat_0_1, float mat_0_2, float mat_1_0, float mat_1_1, float mat_1_2, float mat_2_0, float mat_2_1, float mat_2_2)#

Construct a 3*3 float matrix.

Read parameters in first row the col order.

Matrix3f(const Matrix3f &rhs)#

Deep copy constructor.

It will not share the same references as the source object.

Parameters:

rhs – other Matrix3f.

Matrix3f(Matrix3f &&rhs) noexcept#

Move constructor.

Parameters:

rhs – other rvalue Matrix3f.

Matrix3f operator*(const Matrix3f &rhs) const#

Matrix multiplication.

A * B = C.

Parameters:

rhs – B matrix.

Returns:

Matrix3f C matrix.

float at(size_t row, size_t col) const#

Return the specified array element.

if row or col out of range, an visionflow::excepts::InvalidArgument will be thrown.

Parameters:
  • row – Index along the dimension 1.

  • col – Index along the dimension 2.

Throws:

visionflow::excepts::InvalidArgument – if row or col out of range.

Returns:

NO_DISCARD float array element.

float &at(size_t row, size_t col)#

Return a reference to the specified array element.

if row or col out of range, an visionflow::excepts::InvalidArgument will be thrown.

Parameters:
  • row – Index along the dimension 1.

  • col – Index along the dimension 2.

Throws:

visionflow::excepts::InvalidArgument – if row or col out of range.

Returns:

NO_DISCARD float& array element.

Public Static Attributes

static constexpr size_t kSide = 3#

The matrix row and col number.

enum visionflow::geometry::GeoConvertToIntStrategy#

Enumeration of convert_to_int() implementable strategies.

Values:

enumerator kRoundToNearestInt#

Round to the nearest integer number.

enumerator kRetainIntPart#

Retain only the integer part.

enum visionflow::geometry::GeoIsSampleFailType#

Error and diagnostic flags describing why a geometry is not simple or valid.

  • The enumeration GeoIsSampleFailType defines bitwise diagnostic flags used to describe conditions under which a geometry is considered non-simple or invalid according to the algorithms implemented by is_simple() and is_valid().

  • Each value corresponds to a specific failure condition. Since this is a bit-mask enumeration, multiple flags can be combined using bitwise OR (|) to represent multiple simultaneous issues.

  • Example usage:

    auto result = geometry::return_is_simple(polygon);
    if (result & geometry::kSelfIntersections)
        std::cerr << "Polygon has self-intersections.\n";
    if (result == geometry::kNoFailure)
        std::cout << "Geometry is simple.\n";
    

See also

is_simple()

See also

is_valid()

Note

Values are designed as bit flags (powers of two). A geometry may set multiple flags simultaneously if multiple failure conditions are detected. To test for specific failure types, use bitwise AND (&).

Values:

enumerator kNoFailure = 0#

The geometry is simple/valid.

enumerator kEmpty = 1#

The geometry is empty.

enumerator kDuplicatePoints = 2#

The geometry has (consecutive) duplicate points.

enumerator kSpikes = 4#

The geometry contains spikes.

enumerator kSelfIntersections = 8#

The geometry has self-intersections.

enumerator kPolygonOuterFailure = 16#

The exterior ring of geometry is not simple/valid.

enumerator kPolygonInnersFailure = 32#

The interior rings of geometry is not simple/valid.

enumerator kFewPoints = 64#

The geometry has a very small number of points.

enumerator kWrongTopologicalDimension = 128#

The topological dimension of the geometry is smaller than its dimension.

enumerator kInvalidCoordinate = 256#

The geometry has at least one point with an invalid coordinate.

enumerator kWrongOrientation = 512#

The actual orientation of the geometry is different from the one defined.

enumerator kInteriorRingsOutside = 1024#

The geometry contains interior rings that lie outside the exterior ring.

enumerator kNestedInteriorRings = 2048#

The geometry has nested interior rings.

Geometry algorithms#

void visionflow::geometry::append(visionflow::geometry::IGeometry &geometry, const visionflow::geometry::IGeometry &element)#

Function to append element(s) into the geometry object.

Supported geometry (float-point) types:

geometry

element

LineString

Point, MultiPoint

MultiPoint

Point, MultiPoint

Ring

Point, MultiPoint

Parameters:
  • geometry[inout] The scalable geometry object to which new element(s) will be appended.

  • element[in] Element to append into the geometry object.

group area

Compute the (signed) area of various planar geometry types.

Supported geometry (float-point) types:

geometry_in

Ring

Polygon

Rect

RotateRect

Ellipse

Circle

MultiPolygon

Warning

The result may be affected by geometry conventions such as ring winding direction and data consistency (e.g., self-intersections). Ensure the input geometry is valid according to project conventions before calling.

param geometry_in:

[in] A planar geometry object whose area is to be computed.

Functions

float area(const visionflow::geometry::IGeometry &geometry_in)#
uint32_t area(const visionflow::geometry::Rect2i &geometry_in)#
group equal_operator

Functions that compare a vector with a point for numeric equality.

param lhs:

[in] The vector to compare.

param rhs:

[in] The point to compare against.

return:

bool true if the point and vector are numerically equal; false otherwise.

Functions

bool operator==(const visionflow::geometry::Vector2f &lhs, const visionflow::geometry::Point2f &rhs)#
bool operator==(const visionflow::geometry::Vector2i &lhs, const visionflow::geometry::Point2i &rhs)#
group addition_operator

Operators that add a vector to a point and return a point.

return:

Point2f If either type if float, the result is float point.

return:

Point2i If both types are integer, the result is integer point.

Functions

visionflow::geometry::Point2f operator+(const visionflow::geometry::Vector2f &lhs, const visionflow::geometry::Point2f &rhs)#
visionflow::geometry::Point2i operator+(const visionflow::geometry::Vector2i &lhs, const visionflow::geometry::Point2i &rhs)#
visionflow::geometry::Point2f operator+(const visionflow::geometry::Point2i &lhs, const visionflow::geometry::Vector2f &rhs)#
visionflow::geometry::Point2f operator+(const visionflow::geometry::Vector2f &lhs, const visionflow::geometry::Point2i &rhs)#
group subtraction_operator

Operators that subtract points and/or vectors.

The return type depends on the types of the operands:

group multiplication_operator

Operators that multiply a point or vector by a scalar.

The operation is applied element-wise:

\[ (x, y) \times s = (x \times s,\; y \times s) \]

Functions

visionflow::geometry::Point2f operator*(float lhs, const visionflow::geometry::Point2f &rhs)#
visionflow::geometry::Point2i operator*(int32_t lhs, const visionflow::geometry::Point2i &rhs)#
visionflow::geometry::Vector2f operator*(float lhs, const visionflow::geometry::Vector2f &rhs)#
visionflow::geometry::Vector2i operator*(int32_t lhs, const visionflow::geometry::Vector2i &rhs)#
visionflow::geometry::Point2f operator*(const visionflow::geometry::Point2i &lhs, float rhs)#
visionflow::geometry::Point2f operator*(float lhs, const visionflow::geometry::Point2i &rhs)#
visionflow::geometry::Vector2f operator*(const visionflow::geometry::Vector2i &lhs, float rhs)#
visionflow::geometry::Vector2f operator*(float lhs, const visionflow::geometry::Vector2i &rhs)#
void visionflow::geometry::add_point(visionflow::geometry::IGeometry &target, const visionflow::geometry::IGeometry &increment)#

Add the coordinates of one point geometry to another.

Supported geometry types:

target

increment

Point2f

Point2f

Point2i

Point2i

Parameters:
  • target[inout] The point whose coordinates are to be modified.

  • increment[in] The point providing the coordinate deltas to add to target.

group add_value

Add the same scalar value to both coordinates of a 2D point.

param point:

[inout] The point whose coordinates will be updated.

param value:

[in] A scalar value of the same numeric type as the components of point.

Functions

void add_value(visionflow::geometry::Point2f &point, float value)#
void add_value(visionflow::geometry::Point2i &point, int32_t value)#
group cross_product

Compute the 2D cross product of two points treated as vectors.

param first:

[in] The first input point interpreted as a vector.

param second:

[in] The second input point interpreted as a vector.

return:

The signed scalar cross product value of the two 2D vectors.

Functions

float cross_product(const visionflow::geometry::Point2f &first, const visionflow::geometry::Point2f &second)#
int32_t cross_product(const visionflow::geometry::Point2i &first, const visionflow::geometry::Point2i &second)#
void visionflow::geometry::divide_point(visionflow::geometry::IGeometry &dividend, const visionflow::geometry::IGeometry &divisor)#

Perform component-wise division of one point by another.

Supported geometry types:

dividend

divisor

Point2f

Point2f

Point2i

Point2i

Note

When using integer point type, division uses integer arithmetic (i.e., truncation toward zero) and may lose fractional precision relative to float division.

Parameters:
  • dividend[inout] Each of its coordinate components will be divided by the corresponding component of divisor.

  • divisor[in] The point used as the divisor for coordinate-wise division.

group divide_value

Divide each coordinate of a 2D point by a scalar value.

param point:

[inout] The 2D point whose coordinates will be divided by the scalar.

param value:

[in] The scalar divisor applied to each coordinate of point.

Functions

void divide_value(visionflow::geometry::Point2f &point, float value)#
void divide_value(visionflow::geometry::Point2i &point, int32_t value)#
group dot_product

Compute the scalar dot product of two 2D points or vectors.

param first:

[in] The first input point or vector of the same type.

param second:

[in] The second input point or vector of the same type.

return:

A scalar value of the same numeric type (float or int32_t) representing the dot product of the inputs.

Functions

float dot_product(const visionflow::geometry::Point2f &first, const visionflow::geometry::Point2f &second)#
int32_t dot_product(const visionflow::geometry::Point2i &first, const visionflow::geometry::Point2i &second)#
float dot_product(const visionflow::geometry::Vector2f &first, const visionflow::geometry::Vector2f &second)#
int32_t dot_product(const visionflow::geometry::Vector2i &first, const visionflow::geometry::Vector2i &second)#
void visionflow::geometry::multiply_point(visionflow::geometry::IGeometry &target, const visionflow::geometry::IGeometry &multiplier)#

Perform component-wise multiplication of two 2D points.

Supported geometry types:

target

multiplier

Point2f

Point2f

Point2i

Point2i

Parameters:
  • target[inout] The point whose coordinates are to be updated.

  • multiplier[in] The point providing the coordinate values to multiply with.

group multiply_value

Multiply both coordinates of a 2D point by the same scalar value.

param point:

[inout] The 2D point whose coordinates will be scaled by value.

param value:

[in] The scalar factor to multiply with each coordinate of point.

Functions

void multiply_value(visionflow::geometry::Point2f &point, float value)#
void multiply_value(visionflow::geometry::Point2i &point, int32_t value)#
void visionflow::geometry::subtract_point(visionflow::geometry::IGeometry &minuend, const visionflow::geometry::IGeometry &subtrahend)#

Subtract one 2D point from another (component-wise).

Supported geometry types:

minuend

subtrahend

Point2f

Point2f

Point2i

Point2i

Parameters:
  • minuend[inout] The point whose coordinates will be updated.

  • subtrahend[in] The point to subtract from minuend.

group subtract_value

Subtract a scalar value from both coordinates of a 2D point.

param point:

[inout] The 2D point whose coordinates will be decreased by value.

param value:

[in] The scalar value to subtract from each coordinate of point.

Functions

void subtract_value(visionflow::geometry::Point2f &point, float value)#
void subtract_value(visionflow::geometry::Point2i &point, int32_t value)#
visionflow::geometry::Radian visionflow::geometry::min_angle(const visionflow::geometry::Line2f &line_a, const visionflow::geometry::Line2f &line_b)#

Calculate the minimum angle between two lines.

This function returns the smallest positive angle between the directions of two 2D line geometries. Only the acute angle is returned.

Parameters:
  • line_a[in] The first 2D line.

  • line_b[in] The second 2D line.

Returns:

The acute minimum angle radian of two lines, the range is [0, 𝝅/2].

group azimuth

Compute the azimuth angle of a line segment or vector in 2D.

In 2D Cartesian geometry, the azimuth is the signed angle between the positive X-axis and a direction defined by a line segment or vector. It is typically computed using the two-argument arctangent function (atan2), which returns an angle in radians in the range (-π, π], with positive values corresponding to counter-clockwise rotation from the positive X-axis.

Functions

visionflow::geometry::Radian azimuth(const visionflow::geometry::IGeometry &first, const visionflow::geometry::IGeometry &second)#

Supported geometry types:

Parameters:
  • first[in] The first point (or vector origin) in 2D space.

  • second[in] The second point (or vector end) in 2D space.

Returns:

The signed azimuth angle in radians, representing the rotation from the positive X-axis to the direction from first to second. The result is in the range (-π, π].

visionflow::geometry::Radian azimuth(const visionflow::geometry::IGeometry &vector)#

Supported geometry types:

Parameters:

vector[in] A 2D vector whose direction from the origin (0, 0) is used to determine the azimuth angle.

Returns:

The signed azimuth angle in radians, representing the rotation from the positive X-axis to the direction of vector. The result is in the range (-π, π].

group center

Compute the center (centroid of bounding rectangle) of a geometry.

Supported geometry (float-point) types:

geometry_in

Ring

Polygon

Rect

RotateRect

Ellipse

Circle

MultiPolygon

param geometry_in:

[in] The input area geometry for which the central point is computed.

Functions

visionflow::geometry::Point2f center(const visionflow::geometry::IGeometry &geometry_in)#
visionflow::geometry::Point2i center(const visionflow::geometry::Circle2i &geometry_in)#
group centroid

Compute the geometric centroid of a 2D area geometry.

Supported geometry (float-point) types:

geometry_in

Ring

Polygon

Rect

RotateRect

Ellipse

Circle

MultiPolygon

param geometry_in:

[in] The input area geometry for which to compute the geometric centroid.

Functions

visionflow::geometry::Point2f centroid(const visionflow::geometry::IGeometry &geometry_in)#
visionflow::geometry::Point2i centroid(const visionflow::geometry::Circle2i &geometry_in)#
void visionflow::geometry::clear(visionflow::geometry::IGeometry &geometry_out)#

Remove all coordinate data from a geometric object.

Supported geometry (float-point) types:

geometry_out

LineString

Ring

Polygon

MultiPoint

MultiPolygon

Parameters:

geometry_out[inout] The geometry to be cleared.

void visionflow::geometry::convert(const visionflow::geometry::IGeometry &geometry_in, visionflow::geometry::IGeometry &geometry_out)#

Convert one geometry object to another geometry type.

  • The conversion attempts to reinterpret the structure of the source geometry into the target geometry type, where meaningfully possible. Some conversions may not preserve all geometric semantics or may be approximated.

  • Integer geometry types can be converted to floating-point types without loss of precision. However, converting floating-point types to integer types should use the convert_to_int() function to handle rounding or truncation appropriately.

  • Supported geometry (float-point) types:

    geometry_in / geometry_out

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    Vector

    Segment

    MultiPolygon

    MultiPoint

    Point

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    LineString

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Ring

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Polygon

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Rect

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    RotateRect

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Arc

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Vector

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Segment

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    MultiPoint

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

Note

The algorithm does not guarantee that existing data in the geometry_out will be deleted.

Parameters:
  • geometry_in[in] The input geometry object to convert from.

  • geometry_out[inout] The target geometry object to convert to.

group convert_to_int

Convert floating-point geometry to the corresponding integer geometry type.

Supported geometry (float-point) types:

geometry

Vector

Point

Segment

LineString

Ring

Polygon

Rect

MultiPolygon

MultiPoint

param geometry:

[in] The floating-point geometry to convert.

param strategy:

[in] The conversion strategy that determines how floating-point values are rounded or truncated to integers.

return:

The corresponding integer number type.

Functions

visionflow::geometry::Vector2i convert_to_int(const visionflow::geometry::Vector2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::Point2i convert_to_int(const visionflow::geometry::Point2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::Segment2i convert_to_int(const visionflow::geometry::Segment2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::LineString2i convert_to_int(const visionflow::geometry::LineString2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::Ring2i convert_to_int(const visionflow::geometry::Ring2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::Polygon2i convert_to_int(const visionflow::geometry::Polygon2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::Rect2i convert_to_int(const visionflow::geometry::Rect2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::MultiPolygon2i convert_to_int(const visionflow::geometry::MultiPolygon2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
visionflow::geometry::MultiPoint2i convert_to_int(const visionflow::geometry::MultiPoint2f &geometry, visionflow::geometry::GeoConvertToIntStrategy strategy = visionflow::geometry::kRoundToNearestInt)#
group convex_hull

Compute the convex hull for the given geometry object.

Supported geometry (float-point) types:

geo_obj

Ring

Polygon

MultiPolygon

Note

The hull result is constructed by ordering the extreme points; the starting point is the leftmost (smallest X) coordinate, and vertices proceed in increasing angular order relative to the positive X-axis.

Warning

For inputs with fewer than three distinct points, this function may augment the result up to three points — such results should be treated with caution as they may not form a valid polygon.

param geo_obj:

[in] The geometry to get the convex hull.

return:

The output is always a 2D convex ring representing the vertices of the convex hull in order (e.g., positive rotation measured from +X toward +Y).

Functions

visionflow::geometry::Ring2f convex_hull(const visionflow::geometry::Ring2f &geo_obj)#
visionflow::geometry::Ring2i convex_hull(const visionflow::geometry::Ring2i &geo_obj)#
visionflow::geometry::Ring2f convex_hull(const visionflow::geometry::Polygon2f &geo_obj)#
visionflow::geometry::Ring2i convex_hull(const visionflow::geometry::Polygon2i &geo_obj)#
visionflow::geometry::Ring2f convex_hull(const visionflow::geometry::MultiPolygon2f &geo_obj)#
visionflow::geometry::Ring2i convex_hull(const visionflow::geometry::MultiPolygon2i &geo_obj)#
void visionflow::geometry::correct(visionflow::geometry::IGeometry &geometry_out)#

Normalize a polygon’s vertex order and ensure a consistent open/closed form.

Supported geometry (float-point) types:

geometry_out

Ring

Polygon

MultiPolygon

Parameters:

geometry_out[inout] A polygonal geometry that will be normalized in place.

group return_correct

Return a normalized ring.

See also

correct()

param geometry_in:

[in] A polygonal geometry to be normalized.

Functions

visionflow::geometry::Ring2f return_correct(const visionflow::geometry::Ring2f &geometry_in)#
visionflow::geometry::Ring2i return_correct(const visionflow::geometry::Ring2i &geometry_in)#
visionflow::geometry::Polygon2f return_correct(const visionflow::geometry::Polygon2f &geometry_in)#
visionflow::geometry::Polygon2i return_correct(const visionflow::geometry::Polygon2i &geometry_in)#
visionflow::geometry::MultiPolygon2f return_correct(const visionflow::geometry::MultiPolygon2f &geometry_in)#
visionflow::geometry::MultiPolygon2i return_correct(const visionflow::geometry::MultiPolygon2i &geometry_in)#
bool visionflow::geometry::covered_by(const visionflow::geometry::IGeometry &subject, const visionflow::geometry::IGeometry &container)#

Determine if the first geometry is covered by the second geometry.

  • Checks whether the first geometry is inside or on the boundary of the second geometry. In contrast to within(), covered_by() treats boundary points as covered by default (e.g., a point lying exactly on the boundary of a polygon is considered covered).

  • For two sets the covered_by relationship can be expressed as:

    \[ a.\mathrm{CoveredBy}(b) \quad \Longleftrightarrow \quad \bigl(a \cap b = a \bigr) \]

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{CoveredBy}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap E(b) = \varnothing \bigr) \wedge \\ & \bigl(B(a) \cap E(b) = \varnothing \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    subject / container

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    MultiPolygon

    Point

    LineString

    ×

    ×

    Ring

    ×

    ×

    ×

    Polygon

    ×

    ×

    ×

    Rect

    ×

    ×

    ×

    ×

    RotateRect

    ×

    ×

    ×

    ×

    Circle

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    See also

    within()

Parameters:
  • subject[in] The geometry whose coverage is being tested.

  • container[in] The geometry that may cover subject.

Returns:

bool True if subject is covered by container, false otherwise.

bool visionflow::geometry::crosses(const visionflow::geometry::IGeometry &subject, const visionflow::geometry::IGeometry &other)#

Determine if the first geometry “crosses” the second geometry.

-A geometric cross relationship occurs when two geometries share some but not all of their interior points, and their intersection has a dimension strictly less than the maximum dimension of the two input geometries. In other words, the intersection must be non-empty, cannot equal either geometry, and must be lower dimensional than at least one of them (for example a line crossing a polygon, or two lines crossing at an interior point).

  • For two sets the crosses relationship can be expressed as:

    \[ a.\mathrm{Cross}(b) \quad \Longleftrightarrow \quad \bigl(I(a) \cap I(b) \neq \varnothing \bigr) \wedge \bigl(a \cap b \neq a \bigr) \wedge \bigl(a \cap b \neq b \bigr) \]

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{Cross}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap I(b) \neq \varnothing \bigr) \wedge \\ & \bigl(I(a) \cap E(b) \neq \varnothing \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    subject / other

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    MultiPolygon

    LineString

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

    ×

    ×

  • If the first geometry does not cross the second geometry (for example, if it is entirely inside, entirely outside, or touching only at a boundary), this function will return false.

  • By contrast, the covered_by() predicate returns true when the first geometry lies inside or on the boundary of the second geometry.

See also

covered_by()

Note

Parameters:
  • subject[in] The geometry being tested for crossing.

  • other[in] The geometry being tested against.

Returns:

bool True if subject crosses other, false otherwise.

group difference

Compute the geometric difference between two polygons or polygon-like geometries.

  • Calculates the set difference (A \ B) of two area geometries, returning the parts of subject that are not covered by clip. Implementations typically follow adapted algorithms for robust polygon clipping on 2D shapes.

Functions

visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Ring2f &subject, const visionflow::geometry::Ring2f &clip)#

  • Supported geometry (float-point) types:

    subject / clip

    Ring

    Polygon

    Rect

    RotateRect

    MultiPolygon

    Ring

    Polygon

    Rect

    ×

    RotateRect

    ×

    MultiPolygon

    ×

    ×

Parameters:
  • subject[in] The geometry from which area will be subtracted.

  • clip[in] The geometry whose area will be removed from subject.

Returns:

A MultiPolygon containing all resulting polygonal pieces of subject after removing the region covered by clip. The output may consist of multiple disjoint polygons.

visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Ring2f &subject, const visionflow::geometry::Polygon2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Ring2f &subject, const visionflow::geometry::Rect2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Ring2f &subject, const visionflow::geometry::RotateRect2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Ring2f &subject, const visionflow::geometry::MultiPolygon2f &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Ring2i &subject, const visionflow::geometry::Ring2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Ring2i &subject, const visionflow::geometry::Polygon2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Ring2i &subject, const visionflow::geometry::Rect2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Ring2i &subject, const visionflow::geometry::RotateRect2i &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Polygon2f &subject, const visionflow::geometry::Ring2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Polygon2f &subject, const visionflow::geometry::Polygon2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Polygon2f &subject, const visionflow::geometry::Rect2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Polygon2f &subject, const visionflow::geometry::RotateRect2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Polygon2f &subject, const visionflow::geometry::MultiPolygon2f &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Polygon2i &subject, const visionflow::geometry::Ring2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Polygon2i &subject, const visionflow::geometry::Polygon2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Polygon2i &subject, const visionflow::geometry::Rect2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Polygon2i &subject, const visionflow::geometry::RotateRect2i &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Rect2f &subject, const visionflow::geometry::Ring2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Rect2f &subject, const visionflow::geometry::Polygon2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Rect2f &subject, const visionflow::geometry::Rect2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::Rect2f &subject, const visionflow::geometry::RotateRect2f &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Rect2i &subject, const visionflow::geometry::Ring2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Rect2i &subject, const visionflow::geometry::Polygon2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Rect2i &subject, const visionflow::geometry::Rect2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::Rect2i &subject, const visionflow::geometry::RotateRect2i &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::RotateRect2f &subject, const visionflow::geometry::Ring2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::RotateRect2f &subject, const visionflow::geometry::Polygon2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::RotateRect2f &subject, const visionflow::geometry::Rect2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::RotateRect2f &subject, const visionflow::geometry::RotateRect2f &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::RotateRect2i &subject, const visionflow::geometry::Ring2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::RotateRect2i &subject, const visionflow::geometry::Polygon2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::RotateRect2i &subject, const visionflow::geometry::Rect2i &clip)#
visionflow::geometry::MultiPolygon2i difference(const visionflow::geometry::RotateRect2i &subject, const visionflow::geometry::RotateRect2i &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::MultiPolygon2f &subject, const visionflow::geometry::MultiPolygon2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::MultiPolygon2f &subject, const visionflow::geometry::Ring2f &clip)#
visionflow::geometry::MultiPolygon2f difference(const visionflow::geometry::MultiPolygon2f &subject, const visionflow::geometry::Polygon2f &clip)#
float visionflow::geometry::discrete_frechet_distance(const visionflow::geometry::IGeometry &curve1, const visionflow::geometry::IGeometry &curve2)#

Compute the discrete Fréchet distance between two curves.

  • The Fréchet distance is a measure of similarity between two curves that accounts for the ordering of points along each curve as well as their spatial positions.

  • Supported geometry (float-point) types:

    curve1 / curve2

    LineString

    LineString

Parameters:
  • curve1[in] The first curve.

  • curve2[in] The second curve of the same type as curve1.

Returns:

A non-negative floating-point value representing the discrete Fréchet distance between the two curves. Smaller values indicate greater similarity, with zero indicating identical curves (subject to the discrete vertex representation).

bool visionflow::geometry::disjoint(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Check whether two geometries are disjoint.

  • In geometry and computational geometry, disjoint means that two (or more) objects have no points in common — they do not touch or overlap in any way. It’s the opposite of intersects.

    • Example: Two circles are disjoint if the distance between their centers is greater than the sum of their radii.

    • Example: Two line segments are disjoint if they do not intersect at any point, including endpoints.

  • Formally, for two sets \(A\) and \(B\) in space:

    \[ A \cap B = \varnothing \quad \Rightarrow \quad \text{A and B are disjoint.} \]
    Here, \(\varnothing\) means the empty set, so their intersection has no elements.

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{Disjoint}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap I(b) = \varnothing \bigr) \wedge \\ & \bigl(I(a) \cap B(b) = \varnothing \bigr) \wedge \\ & \bigl(B(a) \cap I(b) = \varnothing \bigr) \wedge \\ & \bigl(B(a) \cap B(b) = \varnothing \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    MultiPolygon

    Line

    Ellipse

    Point

    ×

    ×

    ×

    LineString

    ×

    ×

    ×

    Ring

    ×

    ×

    Polygon

    ×

    ×

    Rect

    ×

    ×

    RotateRect

    ×

    ×

    ×

    Circle

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    Line

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Ellipse

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

  • The predicate returns true only when no point, boundary, or interior of one geometry intersects that of the other.

  • This is the complement of the intersects predicate: if two geometries intersect (share any common point), then they are not disjoint.

See also

intersects()

Note

Parameters:
  • geometry1[in] The first geometry to test.

  • geometry2[in] The second geometry to test against.

Returns:

bool true if the two geometries share no points in common; otherwise false.

float visionflow::geometry::distance(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Get the distance between two geometries.

  • This function treats two-dimensional plane geometric figures as planes filled with internal content rather than as sets of line segments composed solely of boundaries. For example, if a point falls within a circle, then regardless of the specific location of the point, the distance from the point to the circle is always 0.

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    Segment

    Line

    MultiPolygon

    Point

    ×

    LineString

    ×

    Ring

    ×

    Polygon

    ×

    Rect

    ×

    RotateRect

    ×

    Circle

    ×

    ×

    ×

    Segment

    ×

    Line

    ×

    MultiPolygon

    ×

Parameters:
  • geometry1[in] The first geometry.

  • geometry2[in] The second geometry.

Returns:

float The distance between the two geometries.

float visionflow::geometry::distance_min(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Calculate the minimum distance between two geometry shapes.

  • Assume there is a moving point A on a geometry shape and a moving point B on another geometry shape, then calculate the minimum distance between them. Different from distance, this function calculates geometric shapes as lines formed by boundaries rather than planes.

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Point

    Line

    Segment

    Circle

    Ellipse

    Ring

    Polygon

    MultiPolygon

    Point

    ×

    ×

    ×

    ×

    ×

    Line

    ×

    ×

    ×

    ×

    ×

    Segment

    ×

    ×

    ×

    Circle

    ×

    ×

    ×

    ×

    Ellipse

    ×

    ×

    ×

    ×

    ×

    Ring

    ×

    ×

    ×

    ×

    ×

    Polygon

    ×

    ×

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

Parameters:
  • geometry1[in] The first geometry shape.

  • geometry2[in] The second geometry shape.

Returns:

float Return the minimum distance between moving points on two geometry shapes.

float visionflow::geometry::distance_max(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Calculate the maximum distance between two geometry shape.

  • Assume there is a moving point A on a geometry shape and a moving point B on another geometry shape, then calculate the maximum distance between them. Different from distance, this function calculates geometric shapes as lines formed by boundaries rather than planes.

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Point

    Line

    Segment

    Circle

    Ellipse

    Point

    ×

    ×

    Line

    ×

    ×

    Segment

    Circle

    ×

    Ellipse

    ×

    ×

Parameters:
  • geometry1[in] The first geometry shape.

  • geometry2[in] The second geometry shape.

Returns:

float Return the maximum distance between moving points on two geometry shapes.

group envelope

Compute the minimum bounding rectangle of a geometry.

  • The envelope of a geometry is the minimum axis-aligned bounding rectangle that fully contains the input geometry. In computational geometry, this is also referred to as the bounding box, and it represents the smallest rectangle aligned with the coordinate axes that encloses all points of the geometry.

  • Supported geometry (float-point) types:

    geometry_in

    LineString

    Ring

    Polygon

    RotateRect

    MultiPolygon

    MultiPoint

    Ellipse

param geometry_in:

[in] The input geometry for which to compute the minimum bounding rectangle.

return:

A Rect representing the axis-aligned rectangle that minimally contains the input geometry.

Functions

visionflow::geometry::Rect2f envelope(const visionflow::geometry::LineString2f &geometry_in)#
visionflow::geometry::Rect2i envelope(const visionflow::geometry::LineString2i &geometry_in)#
visionflow::geometry::Rect2f envelope(const visionflow::geometry::Ring2f &geometry_in)#
visionflow::geometry::Rect2i envelope(const visionflow::geometry::Ring2i &geometry_in)#
visionflow::geometry::Rect2f envelope(const visionflow::geometry::Polygon2f &geometry_in)#
visionflow::geometry::Rect2i envelope(const visionflow::geometry::Polygon2i &geometry_in)#
visionflow::geometry::Rect2f envelope(const visionflow::geometry::RotateRect2f &geometry_in)#
visionflow::geometry::Rect2i envelope(const visionflow::geometry::RotateRect2i &geometry_in)#
visionflow::geometry::Rect2f envelope(const visionflow::geometry::MultiPolygon2f &geometry_in)#
visionflow::geometry::Rect2i envelope(const visionflow::geometry::MultiPolygon2i &geometry_in)#
visionflow::geometry::Rect2f envelope(const visionflow::geometry::MultiPoint2f &geometry_in)#
visionflow::geometry::Rect2f envelope(const visionflow::geometry::Ellipse2f &geometry_in)#
bool visionflow::geometry::equals(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Check whether two geometries are spatially equal.

  • The equals predicate tests whether two geometries represent exactly the same point set in space — that is, every point that lies in the first geometry also lies in the second, and vice versa.

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    Vector

    Line

    MultiPoint

    MultiPolygon

    Point

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    LineString

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Ring

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Polygon

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Rect

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    RotateRect

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Circle

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Vector

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Line

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    MultiPoint

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

Parameters:
  • geometry1[in] The first geometry to compare.

  • geometry2[in] The second geometry with same type to compare.

Returns:

bool true if the two geometries represent the same set of points; otherwise false.

visionflow::geometry::MultiSegment2f visionflow::geometry::segment_sampling(const visionflow::geometry::IGeometry &geometry_in)#

Integer points within a geometry.

  • Sampling from small to large along the y-axis and compressing from small to large along the x-axis.

  • For a line segment whose ends are exactly on the integer point, only the smaller y-axis coordinate is retained.

  • This also means that for line segments parallel to the x-axis in a geometry, only those located on the smaller of the y-axis will be retained.

  • Supported geometry (float-point) types:

    geometry_in

    Ring

    Polygon

    MultiPolygon

Parameters:

geometry_in[in] Input geometry.

Returns:

MultiSegment2f The result of compressing consecutive points.

group intersection

Compute the geometric intersection between two shapes.

  • This module defines overloads for the intersection of pairs of geometric primitives and composite types. Each function returns the set of points, segments, or polygons representing the geometric intersection of the operands.

Functions

visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Point2f &geometry1, const visionflow::geometry::Point2f &geometry2)#

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    MultiPolygon

    Segment

    Line

    Circle

    Ellipse

    Point

    ×

    ×

    ×

    ×

    ×

    LineString

    ×

    ×

    ×

    ×

    ×

    ×

    Ring

    ×

    ×

    ×

    ×

    Polygon

    ×

    ×

    ×

    ×

    RotateRect

    ×

    ×

    ×

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Segment

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Line

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Circle

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Ellipse

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

Warning

For integer geometric types, if intersection points fall at non-integer coordinates, the floating-point result may be truncated or rounded, possibly leading to precision errors.

Parameters:
  • geometry1[in] The first geometry shape.

  • geometry2[in] The second geometry shape.

visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Point2f &geometry1, const visionflow::geometry::LineString2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Point2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Point2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Point2f &geometry1, const visionflow::geometry::Rect2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Point2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Point2i &geometry1, const visionflow::geometry::Point2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Point2i &geometry1, const visionflow::geometry::LineString2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Point2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Point2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Point2i &geometry1, const visionflow::geometry::Rect2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Point2i &geometry1, const visionflow::geometry::RotateRect2i &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::LineString2f &geometry1, const visionflow::geometry::Point2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::LineString2f &geometry1, const visionflow::geometry::LineString2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::LineString2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::LineString2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::LineString2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::LineString2i &geometry1, const visionflow::geometry::Point2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::LineString2i &geometry1, const visionflow::geometry::LineString2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::LineString2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::LineString2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::LineString2i &geometry1, const visionflow::geometry::RotateRect2i &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Point2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::LineString2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiSegment2f intersection(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Segment2f &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::Point2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::LineString2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::RotateRect2i &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Point2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::LineString2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiSegment2f intersection(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Segment2f &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::Point2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::LineString2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::RotateRect2i &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::Point2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::LineString2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::RotateRect2i &geometry1, const visionflow::geometry::Point2i &geometry2)#
visionflow::geometry::MultiPoint2i intersection(const visionflow::geometry::RotateRect2i &geometry1, const visionflow::geometry::LineString2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::RotateRect2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::RotateRect2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPolygon2i intersection(const visionflow::geometry::RotateRect2i &geometry1, const visionflow::geometry::RotateRect2i &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiSegment2f intersection(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Segment2f &geometry2)#
visionflow::geometry::MultiSegment2f intersection(const visionflow::geometry::Segment2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiSegment2f intersection(const visionflow::geometry::Segment2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiSegment2f intersection(const visionflow::geometry::Segment2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::Point2f intersection(const visionflow::geometry::Line2f &geometry1, const visionflow::geometry::Line2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Line2f &geometry1, const visionflow::geometry::Circle2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Line2f &geometry1, const visionflow::geometry::Ellipse2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Circle2f &geometry1, const visionflow::geometry::Line2f &geometry2)#
visionflow::geometry::MultiPoint2f intersection(const visionflow::geometry::Ellipse2f &geometry1, const visionflow::geometry::Line2f &geometry2)#
visionflow::geometry::MultiPolygon2f intersection(std::vector<visionflow::geometry::MultiPolygon2f> ori)#

Get the intersection results of n Polygon or n MultiPolygon.

Construct std::vector<visionflow::geometry::MultiPolygon2f> using n original data, the final size is n. For example, if original data is n Polygon, you can use like below:

std::vector<geometry::MultiPolygon2f> multi_polygon_vector;
for (size_t i = 0; i < n; ++i) {
    multi_polygon_vector.emplace_back(get_polygon(i));
}
auto res = geometry::intersection(std::move(multi_polygon_vector));

Parameters:

ori[in] Original vector

visionflow::geometry::MultiPoint2f visionflow::geometry::intersection_points(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Calculate the intersection points between two geometry shapes.

  • When two segments overlap, the intersection points are the two endpoints. If a line and a segment overlap, the intersection points are the two endpoints of the segment. When two circles overlap, it’s a point on the circle with a radian of 0.

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Line

    Segment

    Circle

    Ellipse

    Line

    ×

    ×

    ×

    Segment

    Circle

    ×

    ×

    Ellipse

    ×

    ×

    ×

Parameters:
  • geometry1[in] The first geometry shape.

  • geometry2[in] The second geometry shape.

Returns:

The intersection points of geometry1 and geometry2.

bool visionflow::geometry::intersects(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Check whether two geometries intersect or not.

  • In geometry and computational geometry, intersects means that two (or more) objects share at least one point in common — they touch, cross, or overlap in any way. It’s the opposite of disjoint.

    • Example: Two circles intersect if the distance between their centers is less than or equal to the sum of their radii.

    • Example: Two polygons intersect if they have at least one common vertex, edge, or overlapping region.

  • Formally, for two sets \(A\) and \(B\) in space:

    \[ A \cap B \neq \varnothing \quad \Rightarrow \quad \text{A and B intersect.} \]
    Here, \(\neq \varnothing\) means the intersection is not empty.

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{Intersects}(b) \quad \Longleftrightarrow \quad !a.\mathrm{Disjoint}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap I(b) \neq \varnothing \bigr) \vee \\ & \bigl(I(a) \cap B(b) \neq \varnothing \bigr) \vee \\ & \bigl(B(a) \cap I(b) \neq \varnothing \bigr) \vee \\ & \bigl(B(a) \cap B(b) \neq \varnothing \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    MultiPolygon

    Line

    Ellipse

    Point

    ×

    ×

    ×

    LineString

    ×

    ×

    ×

    Ring

    ×

    ×

    Polygon

    ×

    ×

    Rect

    ×

    ×

    RotateRect

    ×

    ×

    ×

    Circle

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

    ×

    Line

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    Ellipse

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

    ×

  • This is the complement of the disjoint predicate: if two geometries disjoint, then they are not intersects.

See also

disjoint()

Note

Parameters:
  • geometry1[in] The first geometry to test.

  • geometry2[in] The second geometry to test against.

Returns:

bool true if the two geometries share at least one point in common; otherwise false.

bool visionflow::geometry::intersects_and_not_touches(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Determines if the specified geometry intersects with another geometry without touching its boundaries.

  • This function checks for an intersection between a geometric object and another specified geometric object, ensuring that the intersection does not merely touch the outer boundary of the shapes, but actually overlaps in their interiors. This method is useful for determining more complex geometric relationships beyond simple intersection or containment.

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{IntersectsAndNotTouches}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap I(b) \neq \varnothing \bigr) \vee \\ & \bigl(I(a) \cap B(b) \neq \varnothing \bigr) \vee \\ & \bigl(B(a) \cap I(b) \neq \varnothing \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Ring

    Polygon

    Rect

    MultiPolygon

    Ring

    Polygon

    Rect

    MultiPolygon

Parameters:
  • geometry1[in] Geometric object.

  • geometry2[in] Another geometric object.

Returns:

bool Returns true if there is an intersection that does not merely touch the boundaries of the geometric shapes; otherwise, it returns false.

float visionflow::geometry::iou(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Compute the Intersection over Union (IoU) of two geometries.

  • This function calculates the Intersection over Union (IoU) metric between two arbitrary geometry objects. IoU is defined as the area of the intersection divided by the area of the union of the two shapes:

    \[ \mathrm{IoU}(A, B) = \frac{\mathrm{area}(A \cap B)} {\mathrm{area}(A \cup B)}, \]

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Ring

    Polygon

    Rect

    RotateRect

    MultiPolygon

    Ring

    Polygon

    Rect

    RotateRect

    MultiPolygon

Parameters:
  • geometry1[in] The first input geometry.

  • geometry2[in] The second input geometry.

Returns:

The IoU value in the range [0.0, 1.0].

bool visionflow::geometry::is_empty(const visionflow::geometry::IGeometry &geometry_in)#

Determine whether a geometry is empty.

Supported geometry (float-point) types:

geometry_in

LineString

Ring

Polygon

MultiPoint

MultiPolygon

Parameters:

geometry_in[in] The geometry to test for emptiness.

Returns:

true if the geometry is empty; false otherwise.

bool visionflow::geometry::is_rect(const visionflow::geometry::IGeometry &geometry)#

Determine whether a geometry can be converted as an axis-aligned or rotated rectangle.

Supported geometry (float-point) types:

geometry

Ring

Parameters:

geometry[in] The input geometry to test for rectangular shape..

Returns:

true if the geometry can be converted to Rect (axis-aligned or rotated); false otherwise.

bool visionflow::geometry::is_axial_rect(const visionflow::geometry::IGeometry &geometry)#

Determine whether a geometry can be converted to an axis-aligned rectangle.

Supported geometry (float-point) types:

geometry

Ring

Parameters:

geometry[in] The input geometry to test for axis-aligned rectangular shape.

Returns:

true if the geometry can be converted to a Rect with sides parallel to the coordinate axes; false otherwise.

bool visionflow::geometry::is_rotate_rect(const visionflow::geometry::IGeometry &geometry)#

Determine whether a geometry can be converted to a rotated rectangle.

Supported geometry (float-point) types:

geometry

Ring

Parameters:

geometry[in] The input geometry to test for rotated rectangular shape.

Returns:

true if the geometry can be converted to a Rect and the Rect is not parallel to coordinate axes; false otherwise.

bool visionflow::geometry::is_simple(const visionflow::geometry::IGeometry &geometry_in)#

Determine whether a geometry is a simple geometry.

  • A simple geometry is one that does not contain anomalous geometric points, such as self-intersections, self-tangency, or repeated vertices. For the supported types:

    • LineString: The geometry must be non-empty, must not self-intersect at any point other than possibly at the endpoints, must have no repeated vertices, and must not exhibit spikey or degenerate segments.

    • Ring: A ring is simple if it is non-empty and contains no repeated interior vertices; closed, non-self-intersecting behavior is required.

    • Polygon: A polygon is simple if its exterior and interior rings (if any) are simple and do not self-intersect.

  • Supported geometry (float-point) types:

    geometry_in

    LineString

    Ring

    Polygon

Parameters:

geometry_in[in] The geometry to test for simplicity.

Returns:

true if the geometry is simple; false otherwise.

visionflow::geometry::GeoIsSampleFailType visionflow::geometry::return_is_simple(const visionflow::geometry::IGeometry &geometry_in)#

Determine whether a geometry is simple, and return a failure code.

See also

is_simple()

Parameters:

geometry_in[in] The geometry to test for simplicity.

Returns:

GeoIsSampleFailType The failure code describing why the geometry is not simple.

bool visionflow::geometry::is_valid(const visionflow::geometry::IGeometry &geometry_in)#

Determine whether a geometry is structurally valid.

  • A valid geometry is one that meets certain structural and topological criteria required to unambiguously represent geometric objects in the plane. Validity rules vary with type:

    • LineString: Must have at least two distinct points and non-zero length; self-intersections are permitted for validity but will fail simplicity tests.

    • Ring: Must be non-empty, have at least three distinct points, be closed (first and last points equal), contain no self-intersections, and meet ring order/orientation requirements.

    • Polygon: The exterior ring and all interior rings must be valid rings; the polygon must not self-intersect; interior rings (holes) must lie completely inside the exterior ring and not overlap other inner rings; nested holes are invalid.

    • MultiPolygon: Each polygon element must be valid.

    • Segment: Must have two distinct endpoints and non-zero length.

  • Supported geometry (float-point) types:

    geometry_in

    LineString

    Ring

    Polygon

    MultiPolygon

    Segment

Parameters:

geometry_in[in] The geometry to test for validity.

Returns:

true if the geometry is valid; false otherwise.

visionflow::geometry::GeoIsSampleFailType visionflow::geometry::return_is_valid(const visionflow::geometry::IGeometry &geometry_in)#

Determine whether a geometry is valid and return detailed failure codes.

Supported geometry (float-point) types:

geometry_in

LineString

Ring

Polygon

Segment

See also

is_valid()

Parameters:

geometry_in[in] The geometry to test for validity.

Returns:

GeoIsSampleFailType The failure code describing why the geometry is not valid.

float visionflow::geometry::length(const visionflow::geometry::IGeometry &geometry_in)#

Compute the length of a linear geometry.

Supported geometry (float-point) types:

geometry_in

LineString

Segment

Vector

Parameters:

geometry_in[in] The input geometry.

Returns:

float The length of the input geometry.

void visionflow::geometry::line_interpolate(const visionflow::geometry::IGeometry &geometry_in, float max_distance, visionflow::geometry::IGeometry &geometry_out)#

Perform linear interpolation along a line geometry.

  • This function computes one or more points interpolated along a linear geometry according to a given distance increment. Interpolation is performed by traversing the input line segments in order and generating new points at regular intervals along the line.

  • Supported geometry (float-point) types:

    geometry_in / geometry_out

    Point

    MultiPoint

    LineString

Warning

Interpolation along integer-valued geometries that yield points at non-integer coordinates may produce floating-point results and incur precision differences.

Parameters:
  • geometry_in[in] The input linear geometry to sample along.

  • max_distance[in] The maximum segment length between interpolated points along the line. Values ≤ 0 may be treated as no interpolation or produce no output. If geometry_out is a Point, the result will be the first point in geometry_in.

  • geometry_out[inout] Receives the result of the interpolation. If geometry_out is not empty, the interpolated points will be appended to the existing geometry.

visionflow::geometry::RotateRect2f visionflow::geometry::min_area_rect(const visionflow::geometry::IGeometry &geometry_in)#

Compute the minimum-area bounding rectangle for an areal geometry.

  • The minimum-area rectangle is typically determined by examining the convex hull of the input geometry and testing candidate orientations aligned with edges of the hull. For each candidate orientation, the projected extents of the hull define the rectangle’s width and height; the minimal such area defines the optimal rectangle.

  • Supported geometry (float-point) types:

    geometry_in

    Ring

    Polygon

    MultiPolygon

    Ellipse

Parameters:

geometry_in[in] A valid areal geometry.

Throws:

visionflow::excepts::InvalidArgument – if the geometry is not valid.

Returns:

The minimum-area enclosing rectangle as a RotateRect2f. The angle is normalized to the range (0, 𝝅/2].

bool visionflow::geometry::overlaps(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Determine whether two polygonal geometries have a partial overlap.

  • This function returns true if geometry1 and geometry2 partially overlap in area — that is, they share some common interior area, but neither geometry completely contains the other. If one geometry fully covers the other without a strict partial intersection, this function returns false.

  • For two sets the overlaps relationship can be expressed as:

    \[ a.\mathrm{Overlaps}(b) \quad \Longleftrightarrow \quad \bigl(dim(I(a)) = dim(I(b)) = dim(I(A) \cap I(b)) \bigr) \wedge \bigl(a \cap b \neq a \bigr) \wedge \bigl(a \cap b \neq b \bigr) \]

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{Overlaps}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap I(b) \neq \varnothing \bigr) \wedge \\ & \bigl(I(a) \cap E(b) \neq \varnothing \bigr) \wedge \\ & \bigl(E(a) \cap I(b) \neq \varnothing \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Ring

    Polygon

    Rect

    MultiPolygon

    Ring

    ×

    ×

    Polygon

    ×

    ×

    Rect

    ×

    ×

    ×

    MultiPolygon

    ×

Parameters:
  • geometry1[in] The first polygonal geometry to compare.

  • geometry2[in] The second polygonal geometry of the same type.

Returns:

bool true if geometry1 and geometry2 partially overlap in area; false if they do not intersect, intersect only on boundaries, one contains the other, or they are of unsupported dimension.

bool visionflow::geometry::overlaps_infinity_intersect_points(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Verify whether two geometry shapes have infinitely many intersection points.

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Line

    Segment

    Circle

    Line

    ×

    Segment

    ×

    Circle

    ×

    ×

Parameters:
  • geometry1[in] The first input geometry to test.

  • geometry2[in] The second input geometry to test.

Returns:

bool true if the two geometries have infinitely many intersection points, false otherwise (finite or no intersections).

group perimeter

Compute the perimeter (boundary length) of a geometry.

Supported geometry (float-point) types:

geometry_in

Ring

Polygon

Rect

RotateRect

Circle

MultiPolygon

param geometry_in:

[in] The input areal geometry.

Functions

float perimeter(const visionflow::geometry::IGeometry &geometry_in)#
uint32_t perimeter(const visionflow::geometry::Rect2i &geometry_in)#
void visionflow::geometry::reverse(visionflow::geometry::IGeometry &geometry_out)#

Reverse the point order of a geometry.

Supported geometry (float-point) types:

geometry_out

LineString

Ring

Polygon

MultiPolygon

Note

The reverse of a (multi)polygon or ring might make a valid geometry invalid because the (counter)clockwise orientation reverses.

Parameters:

geometry_out[inout] The geometry whose point order is to be reversed in place.

group return_reverse

Reverse the point order of a geometry.

See also

reverse()

param geometry_in:

[in] The geometry whose point order is to be reversed in place.

Functions

visionflow::geometry::LineString2f return_reverse(const visionflow::geometry::LineString2f &geometry_in)#
visionflow::geometry::Ring2f return_reverse(const visionflow::geometry::Ring2f &geometry_in)#
visionflow::geometry::Polygon2f return_reverse(const visionflow::geometry::Polygon2f &geometry_in)#
visionflow::geometry::MultiPolygon2f return_reverse(const visionflow::geometry::MultiPolygon2f &geometry_in)#
visionflow::geometry::LineString2i return_reverse(const visionflow::geometry::LineString2i &geometry_in)#
visionflow::geometry::Ring2i return_reverse(const visionflow::geometry::Ring2i &geometry_in)#
visionflow::geometry::Polygon2i return_reverse(const visionflow::geometry::Polygon2i &geometry_in)#
void visionflow::geometry::simplify(visionflow::geometry::IGeometry &geometry_out, float max_distance)#

Simplify the geometry with Douglas-Peucker polygon approximation algorithm, and points smaller than a given threshold are removed.

Supported geometry (float-point) types:

geometry_out

LineString

Ring

Polygon

MultiPolygon

Warning

The result will be forced to be modified as a closure if it’s line.

Parameters:
  • geometry_out[inout] The geometry to be simplified.

  • max_distance[in] The maximum allowed deviation distance for point removal.

group return_simplify

Simplify geometries using the Douglas–Peucker algorithm and return a new instance.

Supported geometry (float-point) types:

geometry_in

LineString

Ring

Polygon

See also

simplify()

param geometry_in:

[in] The geometry to be simplified.

param max_distance:

[in] The maximum allowed deviation distance for point removal.

Functions

visionflow::geometry::LineString2f return_simplify(const visionflow::geometry::LineString2f &geometry_in, float max_distance)#
visionflow::geometry::Ring2f return_simplify(const visionflow::geometry::Ring2f &geometry_in, float max_distance)#
visionflow::geometry::Polygon2f return_simplify(const visionflow::geometry::Polygon2f &geometry_in, float max_distance)#
visionflow::geometry::LineString2i return_simplify(const visionflow::geometry::LineString2i &geometry_in, float max_distance)#
visionflow::geometry::Ring2i return_simplify(const visionflow::geometry::Ring2i &geometry_in, float max_distance)#
visionflow::geometry::Polygon2i return_simplify(const visionflow::geometry::Polygon2i &geometry_in, float max_distance)#
group sym_difference

Compute the symmetric difference of two geometries.

  • The symmetric difference is a Boolean set operation that returns the regions belonging to either of the input geometries but not their intersection. In geometric terms, it yields the non-overlapping portions of the inputs.

Functions

visionflow::geometry::MultiPolygon2f sym_difference(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Ring

    Polygon

    MultiPolygon

    Ring

    ×

    Polygon

    ×

    MultiPolygon

Warning

For integer typed geometries, if intersection computations produce floating-point intermediate values, rounding errors or topological artifacts may occur.

Warning

If input geometries do not follow the expected vertex ordering conventions (for example, exterior rings counter-clockwise and interior rings clockwise), the result may be invalid.

Parameters:
  • geometry1[in] The first input geometry to test.

  • geometry2[in] The second input geometry to test.

Returns:

The symmetric difference of the two input geometries.

visionflow::geometry::MultiPolygon2f sym_difference(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f sym_difference(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f sym_difference(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2i sym_difference(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPolygon2i sym_difference(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPolygon2i sym_difference(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPolygon2i sym_difference(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPolygon2f sym_difference(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f sym_difference(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f sym_difference(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
bool visionflow::geometry::touches(const visionflow::geometry::IGeometry &geometry1, const visionflow::geometry::IGeometry &geometry2)#

Whether two geometries touch (i.e., are tangent without overlapping).

  • A touches relationship is a topological predicate that returns true when the boundaries of the two geometries intersect, but their interiors do not. In other words, the geometries have at least one point in common on their boundaries, yet there is no overlap of their interior regions.

  • For two sets the touches relationship can be expressed as:

    \[ a.\mathrm{Touches}(b) \quad \Longleftrightarrow \quad \bigl(I(a) \cap I(b) = \varnothing \bigr) \wedge \bigl(a \cap b \neq \varnothing \bigr) \]

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{Touches}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap I(b) = \varnothing \bigr) \wedge \\ & \bigl( \bigl(B(a) \cap I(b) \neq \varnothing \bigr) \vee \\ & \bigl(I(a) \cap B(b) \neq \varnothing \bigr) \vee \\ & \bigl(B(a) \cap B(b) \neq \varnothing \bigr) \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Ring

    Polygon

    Rect

    MultiPolygon

    Ring

    Polygon

    Rect

    MultiPolygon

Parameters:
  • geometry1[in] The first input geometry to test.

  • geometry2[in] The second input geometry to test.

Returns:

true if the geometries touch (sharing boundary but not interior), false otherwise.

group union_areal

Compute the geometric union of two areal geometries.

  • The union operation returns the combined area of both input geometries, merging overlapping and adjacent regions into a single continuous geometry. This operation is equivalent to the Boolean OR in set theory.

Functions

visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#

  • Supported geometry (float-point) types:

    geometry1 / geometry2

    Ring

    Polygon

    Rect

    RotateRect

    MultiPolygon

    Ring

    Polygon

    Rect

    RotateRect

    MultiPolygon

Warning

For integer geometries, intersection points may require floating-point precision; rounding can introduce minor topological inconsistencies.

Parameters:
  • geometry1[in] The first input geometry to test.

  • geometry2[in] The second input geometry to test.

visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::Rect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Ring2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::Rect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Polygon2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPolygon2i union_areal(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPolygon2i union_areal(const visionflow::geometry::Ring2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPolygon2i union_areal(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::Ring2i &geometry2)#
visionflow::geometry::MultiPolygon2i union_areal(const visionflow::geometry::Polygon2i &geometry1, const visionflow::geometry::Polygon2i &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::Rect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::MultiPolygon2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Rect2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Rect2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Rect2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Rect2f &geometry1, const visionflow::geometry::Rect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::Rect2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::Ring2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::Polygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::MultiPolygon2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::Rect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(const visionflow::geometry::RotateRect2f &geometry1, const visionflow::geometry::RotateRect2f &geometry2)#
visionflow::geometry::MultiPolygon2f union_areal(std::vector<visionflow::geometry::MultiPolygon2f> ori)#

Get the union_areal results of n Polygon or n Multipolygon.

Construct std::vector<visionflow::geometry::MultiPolygon2f> using n original data, the final size is n. For example, if original data is n Polygon, you can use like below:

std::vector<geometry::MultiPolygon2f> multi_polygon_vector;
for (size_t i = 0; i < n; ++i) {
    multi_polygon_vector.emplace_back((get_polygon(i));
}
auto res = geometry::union_areal(std::move(multi_polygon_vector));

Parameters:

ori[in] Original vector

void visionflow::geometry::unique(visionflow::geometry::IGeometry &geometry_out)#

Remove duplicate or consecutive identical vertices from a geometry.

Supported geometry (float-point) types:

geometry_out

LineString

Ring

Polygon

MultiPolygon

Parameters:

geometry_out[inout] The geometry to be cleaned of duplicate vertices.

group return_unique

Return a new geometry with duplicate vertices removed.

See also

unique()

param geometry_in:

[in] The geometry to be cleaned of duplicate vertices.

Functions

visionflow::geometry::LineString2f return_unique(const visionflow::geometry::LineString2f &geometry_in)#
visionflow::geometry::Ring2f return_unique(const visionflow::geometry::Ring2f &geometry_in)#
visionflow::geometry::Polygon2f return_unique(const visionflow::geometry::Polygon2f &geometry_in)#
visionflow::geometry::MultiPolygon2f return_unique(const visionflow::geometry::MultiPolygon2f &geometry_in)#
visionflow::geometry::LineString2i return_unique(const visionflow::geometry::LineString2i &geometry_in)#
visionflow::geometry::Ring2i return_unique(const visionflow::geometry::Ring2i &geometry_in)#
visionflow::geometry::Polygon2i return_unique(const visionflow::geometry::Polygon2i &geometry_in)#
group vertical

Point to the vertical foot of the line.

Functions

visionflow::geometry::Point2f vertical(const visionflow::geometry::Point2f &point, const visionflow::geometry::Line2f &line)#
visionflow::geometry::Point2f vertical(const visionflow::geometry::Line2f &line, const visionflow::geometry::Point2f &point)#
bool visionflow::geometry::within(const visionflow::geometry::IGeometry &subject, const visionflow::geometry::IGeometry &container)#

Determine whether the subject geometry lies entirely inside the container geometry.

  • This predicate returns true only if every point of subject lies in the interior of container and no points of subject lie outside of container. In other words, subject must be strictly contained by container according to standard spatial predicate semantics.

  • This differs from covered_by(): when a vertex of subject lies exactly on the boundary of container, within returns false, whereas covered_by may return true in that case.

  • If a vertex of container lies on the boundary of subject (for example, container is a concave polygon overlapping subject), within may still return true as long as subject is internally contained.

  • For two sets the within relationship can be expressed as:

    \[ a.\mathrm{Within}(b) \quad \Longleftrightarrow \quad \bigl(a \cap b = a \bigr) \wedge \bigl(I(a) \cap I(b) \neq \varnothing \bigr) \]

  • Expressed in terms of the DE-9IM:

    \[\begin{split}\begin{aligned} a.\mathrm{Within}(b) \quad \Longleftrightarrow \quad & \bigl(I(a) \cap I(b) \neq \varnothing \bigr) \wedge \\ & \bigl(I(a) \cap E(b) = \varnothing \bigr) \wedge \\ & \bigl(B(a) \cap E(b) = \varnothing \bigr) \end{aligned}\end{split}\]

  • Supported geometry (float-point) types:

    subject / container

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Circle

    MultiPolygon

    Point

    LineString

    ×

    ×

    Ring

    ×

    ×

    Polygon

    ×

    ×

    Rect

    ×

    ×

    ×

    RotateRect

    ×

    ×

    ×

    Circle

    ×

    ×

    ×

    MultiPolygon

    ×

    ×

    ×

    ×

    ×

    See also

    covered_by()

Parameters:
  • subject[in] The geometry to test for being inside.

  • container[in] The geometry in which containment is tested.

Returns:

true if subject is strictly within container; false otherwise.

group sampling

Sampling ideal geometry types to point set geometry types. Ideal geometry types is geometry types like Rectangle, Circle, Ellipse, etc. Point set geometry types is geometry types described by vertices, like ring, polygon, etc.

  • It Only support Equiangular sampling currently. The sampling center is the center of the geometry.

  • Note that Arc2f samples point set based on the radian step. Only sample points on the arc between the start radian and end radian, and the sampled point set does not include the center point of the circle, the implementation has following three cases:

    1. When the span of start radian and end radian in [0, 2𝝅), the sampled point set contains the start point and end point of the input Arc2f.

    2. When the span of start radian and end radian is greater than or equal to 2𝝅, only the points are sampled within [start_radian, start_radian + 2𝝅).

    3. When the span of start radian and end radian is less than or equal to the sampling radian step, the number of sampling points is 3, and the radian step is modified to 1/2 of the radian span.

  • Supported geometry (float-point) types:

    geometry

    Circle

    Ellipse

    Arc

param geometry:

[in] Geometry object to be sampling.

param point_num:

The number of sampling points. If point_num is less than 3, it will be set to 3.

Functions

visionflow::geometry::Ring2f sampling(const visionflow::geometry::Arc2f &geometry, visionflow::geometry::Radian radian_step)#
visionflow::geometry::Ring2f sampling(const visionflow::geometry::IGeometry &geometry, size_t point_num)#
visionflow::geometry::MultiPolygon2f visionflow::geometry::buffer(const visionflow::geometry::IGeometry &geometry_in, float distance)#

Erode or dilate geometry objects with the specified distance (Negative value for erode, and positive value for dilate).

Supported geometry (float-point) types:

geometry_in

Ring

Polygon

MultiPolygon

Parameters:
  • geometry_in[in] The geometry object to buffer (dilate or erode).

  • distance[in] The buffer distance.

Returns:

MultiPolygon2f The buffered geometry at the given distance.

visionflow::geometry::Circle2f visionflow::geometry::bounding_circle(const visionflow::geometry::IGeometry &geometry_in)#

Get the bounding circle (with the centroid as the circle center) of the geometry object.

  • This function computes a bounding circle by first determining the centroid of the input geometry and then finding the farthest vertex from that centroid. The result differs from the minimum enclosing circle.

  • Supported geometry (float-point) types:

    geometry_in

    Ring

    Polygon

Parameters:

geometry_in[in] The input geometry object.

Returns:

Circle2f The bounding circle of the input geometry object.

inline double visionflow::geometry::circularity(const visionflow::geometry::IGeometry &geometry_in)#

Get a double value in [0, 1] that represents the circularity of the input geometry.

Supported geometry (float-point) types:

geometry_in

Ring

Polygon

Parameters:

geometry_in[in] The input geometry object.

Returns:

double A double value in [0, 1] that represents the circularity of the input geometry.

group transform_rotate

Geometry rotate transform.

  • Cartesian coordinate system(the origin of the first quadrant is in

    the lower left corner), follow

    Radian definition direction.

  • Supported geometry (float-point) types:

    Geometry

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Ellipse

    Vector

    Segment

    MultiPoint

    MultiPolygon

param geometry:

[in] The input geometry.

param radian:

[in] Rotation radian.

return:

The result is consistent with the input geometry. Specifically, some types will be converted to other types after rotation.

Functions

visionflow::geometry::Point2f transform_rotate(const visionflow::geometry::Point2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::LineString2f transform_rotate(const visionflow::geometry::LineString2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::Ring2f transform_rotate(const visionflow::geometry::Ring2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::Polygon2f transform_rotate(const visionflow::geometry::Polygon2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::RotateRect2f transform_rotate(const visionflow::geometry::RotateRect2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::Ellipse2f transform_rotate(const visionflow::geometry::Ellipse2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::Vector2f transform_rotate(const visionflow::geometry::Vector2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::Segment2f transform_rotate(const visionflow::geometry::Segment2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::MultiPoint2f transform_rotate(const visionflow::geometry::MultiPoint2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::MultiPolygon2f transform_rotate(const visionflow::geometry::MultiPolygon2f &geometry, const visionflow::geometry::Radian &radian)#
visionflow::geometry::RotateRect2f transform_rotate(const visionflow::geometry::Rect2f &rect, const visionflow::geometry::Radian &radian)#
group transform_scale

Geometry scale transform.

Supported geometry (float-point) types:

Geometry

Point

LineString

Ring

Polygon

Rect

RotateRect

Vector

Segment

MultiPoint

MultiPolygon

param geometry:

[in] The input geometry.

param ratio_x:

[in] Scaling ratio direction-x.

param ratio_y:

[in] Scaling ratio direction-y.

return:

The result is consistent with the input geometry. Specifically, some types will be converted to other types after rotation.

Functions

visionflow::geometry::Point2f transform_scale(const visionflow::geometry::Point2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::LineString2f transform_scale(const visionflow::geometry::LineString2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::Ring2f transform_scale(const visionflow::geometry::Ring2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::Polygon2f transform_scale(const visionflow::geometry::Polygon2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::Rect2f transform_scale(const visionflow::geometry::Rect2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::Vector2f transform_scale(const visionflow::geometry::Vector2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::Segment2f transform_scale(const visionflow::geometry::Segment2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::MultiPoint2f transform_scale(const visionflow::geometry::MultiPoint2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::MultiPolygon2f transform_scale(const visionflow::geometry::MultiPolygon2f &geometry, float ratio_x, float ratio_y)#
visionflow::geometry::Ring2f transform_scale(const visionflow::geometry::RotateRect2f &rotate_rect, float ratio_x, float ratio_y)#
group transform_translate

Geometry translate transform.

Supported geometry (float-point) types:

Geometry

Point

LineString

Ring

Polygon

Rect

RotateRect

Ellipse

Vector

Segment

MultiPoint

MultiPolygon

param geometry:

[in] The input geometry.

param offset_x:

[in] Translation transform direction-x.

param offset_y:

[in] Translation transform direction-y.

return:

The result is consistent with the input geometry.

Functions

visionflow::geometry::Point2f transform_translate(const visionflow::geometry::Point2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::LineString2f transform_translate(const visionflow::geometry::LineString2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::Ring2f transform_translate(const visionflow::geometry::Ring2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::Polygon2f transform_translate(const visionflow::geometry::Polygon2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::Rect2f transform_translate(const visionflow::geometry::Rect2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::RotateRect2f transform_translate(const visionflow::geometry::RotateRect2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::Ellipse2f transform_translate(const visionflow::geometry::Ellipse2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::Vector2f transform_translate(const visionflow::geometry::Vector2f &vector, float offset_x, float offset_y)#
visionflow::geometry::Segment2f transform_translate(const visionflow::geometry::Segment2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::MultiPoint2f transform_translate(const visionflow::geometry::MultiPoint2f &geometry, float offset_x, float offset_y)#
visionflow::geometry::MultiPolygon2f transform_translate(const visionflow::geometry::MultiPolygon2f &geometry, float offset_x, float offset_y)#
group transform

Geometry transform.

  • transform(geometry, step1), transform(geometry, step2) -> transform(geometry, step2 * step1).

  • Supported geometry (float-point) types:

    Geometry

    Point

    LineString

    Ring

    Polygon

    Rect

    RotateRect

    Vector

    Segment

    MultiPoint

    MultiPolygon

param geometry:

[in] The input geometry.

param mat:

[in] Transformation matrix.

return:

The result is consistent with the input geometry. Specifically, some types will be converted to other types after rotation.

Functions

visionflow::geometry::Point2f transform(const visionflow::geometry::Point2f &geometry, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::LineString2f transform(const visionflow::geometry::LineString2f &geometry, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::Ring2f transform(const visionflow::geometry::Ring2f &geometry, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::Polygon2f transform(const visionflow::geometry::Polygon2f &geometry, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::Vector2f transform(const visionflow::geometry::Vector2f &vector, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::Segment2f transform(const visionflow::geometry::Segment2f &geometry, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::MultiPoint2f transform(const visionflow::geometry::MultiPoint2f &geometry, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::MultiPolygon2f transform(const visionflow::geometry::MultiPolygon2f &geometry, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::Ring2f transform(const visionflow::geometry::Rect2f &rect, const visionflow::geometry::Matrix3f &mat)#
visionflow::geometry::Ring2f transform(const visionflow::geometry::RotateRect2f &rotate_rect, const visionflow::geometry::Matrix3f &mat)#
Matrix3f visionflow::geometry::get_affine_transform(const std::vector<Point2f> &src, const std::vector<Point2f> &dst)#

Calculate an affine transform from three pairs of the corresponding points.

If the number of point pairs is less than 3, an visionflow::excepts::InvalidArgument will be thrown.

Parameters:
  • src[in] Coordinate of triangle vertices in the source image.

  • dst[in] Coordinate of the corresponding triangle vertices in the destination image.

Throws:

visionflow::excepts::InvalidArgument – if the number of point pairs is less than requirement.

Returns:

Matrix3f The transformation matrix.

Matrix3f visionflow::geometry::get_perspective_transform(const std::vector<Point2f> &src, const std::vector<Point2f> &dst)#

Calculate a perspective transform from four pairs of the corresponding points.

If the number of point pairs is less than 4, an visionflow::excepts::InvalidArgument will be thrown.

Parameters:
  • src[in] Coordinate of quadrangle vertices in the source image.

  • dst[in] Coordinate of the corresponding quadrangle vertices in the destination image.

Throws:

visionflow::excepts::InvalidArgument – if the number of point pairs is less than requirement.

Returns:

Matrix3f The transformation matrix.

Matrix3f visionflow::geometry::get_inverse_transform(const Matrix3f &mat)#

Get inverse transform matrix.

Parameters:

mat[in] Source matrix.

Returns:

Matrix3f Inverse transform matrix.

Matrix3f visionflow::geometry::get_rotate_transform(const Radian &theta)#

Get rotate transform matrix.

Follow Radian definition direction, and the matrix is:

\[\begin{split}\begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}\end{split}\]

Parameters:

theta[in] Rotation radian.

Returns:

Matrix3f Rotate transform matrix.

Matrix3f visionflow::geometry::get_rotate_transform(const Point2f &center, const Radian &theta)#

Get the transformation matrix rotated around a given center.

Let the center pos be \( (x_c, y_c) \), then the transform matrix is:

\[\begin{split}\begin{bmatrix} \cos\theta & -\sin\theta & (1 - \cos\theta) x_c + \sin\theta * y_c \\ \sin\theta & \cos\theta & -\sin\theta * x_c + (1 - \cos\theta) y_c \\ 0 & 0 & 1 \end{bmatrix}\end{split}\]

Parameters:
  • center[in] The rotate center.

  • theta[in] Rotation radian.

Returns:

Matrix3f Rotate transform matrix.

Matrix3f visionflow::geometry::get_scale_transform(float s_x, float s_y)#

Get scale transform matrix.

The matrix is:

\[\begin{split}\begin{bmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 \end{bmatrix}\end{split}\]

Parameters:
  • s_x[in] Scaling ratio direction-x.

  • s_y[in] Scaling ratio direction-y.

Returns:

Matrix3f Scale transform matrix.

Matrix3f visionflow::geometry::get_scale_transform(const Point2f &center, float s_x, float s_y)#

Get the transformation matrix scaled to the given point.

Let the center pos be \( (x_c, y_c) \), then the transform matrix is:

\[\begin{split}\begin{bmatrix} s_x & 0 & (1 - s_x) x_c \\ 1 & s_y & (1 - s_y) y_c \\ 0 & 0 & 1 \end{bmatrix}\end{split}\]

Parameters:
  • center[in] The scale center.

  • s_x[in] Scaling ratio direction-x.

  • s_y[in] Scaling ratio direction-y.

Returns:

Matrix3f Scale transform matrix.

Matrix3f visionflow::geometry::get_translate_transform(float offset_x, float offset_y)#

Get translate transform matrix.

Parameters:
  • offset_x[in] Translation transform direction-x.

  • offset_y[in] Translation transform direction-y.

Returns:

Matrix3f Translate transform matrix.

Matrix3f visionflow::geometry::get_flip_transform(const Line2f &flip_axis)#

Get the mirror flip transform matrix.

Let the symmetrical axis for mirror flip be \( ax + by + c = 0 \), then the transform matrix is:

\[\begin{split}\begin{bmatrix} (b^2 - a^2)/(a^2+b^2) & -2ab/(a^2+b^2) & -2ac/(a^2+b^2) \\ -2ab/(a^2+b^2) & (a^2 - b^2)/(a^2+b^2) & -2bc/(a^2+b^2) \\ 0 & 0 & 1 \end{bmatrix}\end{split}\]

Parameters:

flip_axis[in] The symmetrical axis for mirror flip.

Returns:

Matrix3f flip transform matrix

group polar_transform

Convert points in Cartesian coordinate system to polar coordinate system.

param geometry:

[in] The input geometry to be transformed.

param center:

[in] The transformation center.

param radius:

[in] The radius of the bounding circle to transform.

return:

Points in polar coordinate system.

Functions

visionflow::geometry::Ring2f polar_transform(const visionflow::geometry::Ring2f &geometry, const visionflow::geometry::Point2f &center, float radius)#
visionflow::geometry::MultiPolygon2f polar_transform(const visionflow::geometry::MultiPolygon2f &geometry, const visionflow::geometry::Point2f &center, float radius)#
group inverse_polar_transform

Convert points in polar coordinate system to Cartesian coordinate system.

system.

param geometry:

[in] The input geometry to be transformed.

param center:

[in] The transformation center.

param radius:

[in] The radius of the bounding circle to transform.

return:

Points in Cartesian coordinate system.

Functions

visionflow::geometry::Ring2f inverse_polar_transform(const visionflow::geometry::Ring2f &geometry, const visionflow::geometry::Point2f &center, float radius)#
visionflow::geometry::MultiPolygon2f inverse_polar_transform(const visionflow::geometry::MultiPolygon2f &geometry, const visionflow::geometry::Point2f &center, float radius)#