3D Geometry Structure and Algorithm#

3D Geometry Structure#

class IGeo3d#

Common abstract base class for all 3D geometry types.

Subclassed by visionflow::geo3d::Line3f, visionflow::geo3d::Plane3f, visionflow::geo3d::Point3f, visionflow::geo3d::Vector3f

Public Types

enum Geo3dType#

3D geometry enum value.

Values:

enumerator kPoint3f = 0#
enumerator kVector3f = 1#
enumerator kLine3f = 2#
enumerator kPlane3f = 3#

Public Functions

virtual IGeo3d::Geo3dType type() const = 0#

Enumerate value of geometry types.

Returns:

Geo3dType

const char *type_name() const#

Name of geometry types.

Returns:

const char*

inline virtual bool is_solid() const#

Get if the geometry object is a solid.

Returns:

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

struct Point3f : public visionflow::geo3d::IGeo3d#

Floating point 3D coordinate points.

Public Functions

Point3f() = default#

< Default constructor,no initialization.

Constructor with three values.

Point3f(float x, float y, float z)#

Constructor with a Vector.

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

Numerical comparison with vectors of the same type.

Translation of points

Point3f operator+(const Vector3f &rhs) const#

Translation of points.

Point3f operator-(const Vector3f &rhs) const#

Enlarge point coordinates.

Point3f operator*(float rhs) const#

Point coordinates reduced.

Point3f operator/(float rhs) const#

Translation of points.

Point3f &operator+=(const Vector3f &rhs)#

Translation of points.

Point3f &operator-=(const Vector3f &rhs)#

Enlarge point coordinates.

Point3f &operator*=(float rhs)#

Point coordinates reduced.

Point3f &operator/=(float rhs)#

dot product

virtual IGeo3d::Geo3dType type() const override#

x coordinate

Public Members

float x = 0#

y coordinate

float y = 0#

z coordinate

struct Vector3f : public visionflow::geo3d::IGeo3d#

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

Public Functions

Vector3f() = default#

< Default constructor,no initialization.

Constructor with three values.

Vector3f(float x, float y, float z)#

Constructor with a Point.

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

Inversion of vectors.

Vector3f operator-() const#

Addition of vectors.

Vector3f operator+(const Vector3f &rhs) const#

Subtraction of vectors.

Vector3f operator-(const Vector3f &rhs) const#

Amplification of vectors.

Vector3f operator*(float rhs) const#

Reduction of vectors.

Vector3f operator/(float rhs) const#

vector dot product

float operator*(const Vector3f &rhs) const#

vector cross product

Vector3f operator^(const Vector3f &rhs) const#

Addition of vectors.

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

Subtraction of vectors.

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

Amplification of vectors.

Vector3f &operator*=(float rhs)#

Reduction of vectors.

virtual IGeo3d::Geo3dType type() const override#

Enumerate value of geometry types.

Returns:

Geo3dType

Vector3f normalize() const#

Normalized vector.

Returns:

Vector3f Normalized vector.

float length() const#

Norm of a vector.

Returns:

float Norm length.

bool is_parallel_to(const Vector3f &vec) const#

Verify whether two vectors are parallel.

struct Plane3f : public visionflow::geo3d::IGeo3d#

3D float point plane.

Public Functions

Plane3f() = default#

< Default constructor,no initialization.

Plane3f(float a, float b, float c, float d)#

Constructor with ax+by+cz+d=0.

Plane3f(const Point3f &lhs, const Vector3f &rhs)#

Constructor with a Point on the Plane and the normal Vector (a vector perpendicular to the plane) of the Plane.

Plane3f(const Point3f &lhs, const Point3f &mhs, const Point3f &rhs)#

Constructor with three Points.

Plane3f(float x_intercept, float y_intercept, float z_intercept)#

Constructor with x/x_intercept+y/y_intercept+z/z_intercept=1.

virtual IGeo3d::Geo3dType type() const override#

Enumerate value of geometry types.

Returns:

Geo3dType

Vector3f norm() const#

plane’s normal.

visionflow::geometry::Radian angle_x_normal_project() const#

the angle between x positive axis and vector projected by normal vector on xy plane, the range is (-𝝅, 𝝅].

visionflow::geometry::Radian angle_z_normal() const#

angle between normal and z axis, the range is [0, 𝝅].

Point3f perpendicular_foot(const Point3f &point) const#

perpendicular foot from point to plane

float distance_along_x_axis(const Point3f &point) const#

The distance from the point to the plane along x axis.

Parameters:

point – the point to calculate distance.

Returns:

Distance from the point to the plane along x axis, note that the distance is infinity if plane is parallel to the x axis.

float distance_along_y_axis(const Point3f &point) const#

The distance from the point to the plane along y axis.

Parameters:

point – the point to calculate distance.

Returns:

Distance from the point to the plane along y axis, note that the distance is infinity if plane is parallel to the y axis.

float distance_along_z_axis(const Point3f &point) const#

The distance from the point to the plane along z axis.

Parameters:

point – the point to calculate distance.

Returns:

Distance from the point to the plane along z axis, note that the distance is infinity if plane is parallel to the z axis.

struct Line3f : public visionflow::geo3d::IGeo3d#

3D float point straight line.

Public Functions

Line3f() = default#

< Default constructor,no initialization.

Line3f(const Plane3f &lhs, const Plane3f &rhs)#

Constructor with two Planes.

Line3f(const Point3f &lhs, const Point3f &rhs)#

Constructor with two Points.

Line3f(Point3f lhs, const Vector3f &rhs)#

Constructor with a Point on the Line and the direction Vector of the Line.

virtual IGeo3d::Geo3dType type() const override#

Enumerate value of geometry types.

Returns:

Geo3dType

Point3f perpendicular_foot(const Point3f &point) const#

Perpendicular foot of given point to the line.

Parameters:

point – The point to calculate perpendicular foot.

Returns:

Perpendicular foot point. The point one the line.

Public Members

Point3f point_#

The normalized direction vector on the line, note that its length is 1.

3D Geometry algorithms#

group distance_geo3d

Calculate the distance between two 3D geometry shapes.

shapes.

param lhs:

[in] geometry shape

param rhs:

[in] geometry shape

param result:

[out] The distance between geo1 and geo2

Functions

float distance(const visionflow::geo3d::Point3f &lhs, const visionflow::geo3d::Point3f &rhs)#
float distance(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Line3f &rhs)#
float distance(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
float distance(const visionflow::geo3d::Point3f &lhs, const visionflow::geo3d::Line3f &rhs)#
float distance(const visionflow::geo3d::Point3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
float distance(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
float distance(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Point3f &rhs)#
float distance(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Point3f &rhs)#
float distance(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Line3f &rhs)#
group intersection_geo3d

Calculate the intersection between the input 3D geometry shapes.

the input 3D geometry shapes.

throws excepts::InvalidArgument:

If the input 3D geometry shapes do not intersect.

param lhs:

[in] geometry shape

param rhs:

[in] geometry shape

param result:

[out] The intersection of geo1 and geo2

Functions

visionflow::geo3d::Point3f intersection(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Line3f &rhs)#
visionflow::geo3d::Line3f intersection(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
group intersection_point

Calculate the intersection point between the input 3D geometry shapes.

the input 3D geometry shapes.

throws excepts::InvalidArgument:

If the input 3D geometry shapes do not have an intersection point.

param lhs:

[in] geometry shape

param rhs:

[in] geometry shape

param result:

[out] The intersection point of geo1 and geo2

Functions

visionflow::geo3d::Point3f intersection_point(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
visionflow::geo3d::Point3f intersection_point(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Line3f &rhs)#
visionflow::geo3d::Point3f intersection_point(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Plane3f &mhs, const visionflow::geo3d::Plane3f &rhs)#
group intersects_one_point_geo3d

Verify if two 3D geometry shape have only one intersection point.

shapes have only one intersection point.

param lhs:

[in] geometry shape

param rhs:

[in] geometry shape

Functions

bool intersects_one_point(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
bool intersects_one_point(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Line3f &rhs)#
bool intersects_one_point(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Plane3f &mhs, const visionflow::geo3d::Plane3f &rhs)#
group intersects_geo3d

Verify if two 3D geometry shape intersect.

shapes intersect (at least one intersection point).

param lhs:

[in] geometry shape

param rhs:

[in] geometry shape

Functions

bool intersects(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Line3f &rhs)#
bool intersects(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
group min_angle_geo3d

Calculate the minimum angle between two 3D geometry shapes.

geometry shapes.

param lhs:

geometry shape

param rhs:

geometry shape

return:

The acute minimum angle radian of two 3D geometry shapes, the range is [0, 𝝅/2]

Functions

visionflow::geometry::Radian min_angle(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Line3f &rhs)#
visionflow::geometry::Radian min_angle(const visionflow::geo3d::Line3f &lhs, const visionflow::geo3d::Plane3f &rhs)#
visionflow::geometry::Radian min_angle(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Line3f &rhs)#
visionflow::geometry::Radian min_angle(const visionflow::geo3d::Plane3f &lhs, const visionflow::geo3d::Plane3f &rhs)#