22 static_assert(std::is_trivially_copyable_v<TPlane>);
26 return dotProduct<3, double>(
coefs, point) +
coefs[3];
35 return std::abs(
getAngle(*
this, line)) <
52 for (
int i = 0; i < 3; i++) v[i] =
coefs[i];
59 const double s = sqrt(squareNorm<3, double>(
coefs));
61 const double k = 1.0 / s;
62 for (
int i = 0; i < 3; i++) vec[i] =
coefs[i] * k;
68 double s = sqrt(squareNorm<3, double>(
coefs));
69 for (
double& coef :
coefs) coef /= s;
77 for (
size_t i = 0; i < 3; i++)
89 throw std::logic_error(
"Base point is not in the plane.");
92 for (
size_t i = 0; i < 3; i++) AXIS(i, 3) = center[i];
97 double dx1 = p2.
x - p1.
x;
98 double dy1 = p2.
y - p1.
y;
99 double dz1 = p2.
z - p1.
z;
100 double dx2 = p3.
x - p1.
x;
101 double dy2 = p3.
y - p1.
y;
102 double dz2 = p3.
z - p1.
z;
103 coefs[0] = dy1 * dz2 - dy2 * dz1;
104 coefs[1] = dz1 * dx2 - dz2 * dx1;
105 coefs[2] = dx1 * dy2 - dx2 * dy1;
108 throw std::logic_error(
"Points are linearly dependent");
113 double dx1 = p1.
x - r2.
pBase.
x;
114 double dy1 = p1.
y - r2.
pBase.
y;
115 double dz1 = p1.
z - r2.
pBase.
z;
121 throw std::logic_error(
"Point is contained in the line");
126 const double normal_norm = normal.
norm();
130 const auto n = normal * (1. / normal_norm);
145 if (r1.
contains(r2.
pBase))
throw std::logic_error(
"Lines are the same");
149 for (
size_t i = 0; i < 3; i++) d[i] = r1.
pBase[i] - r2.
pBase[i];
155 throw std::logic_error(
"Lines do not intersect");
A compile-time fixed-size numeric matrix container.
This file implements several operations that operate element-wise on individual or pairs of container...
void fromHomogeneousMatrix(const mrpt::math::CMatrixDouble44 &HG)
TPoint3D pBase
Base point.
TVector3D getUnitaryNormalVector() const
Get normal vector.
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both.
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrixD::Ptr &pObj)
void getAsPose3D(mrpt::math::TPose3D &outPose) const
This base provides a set of functions for maths stuff.
double evaluatePoint(const TPoint3D &point) const
Evaluate a point in the plane's equation.
void getAsPose3DForcingOrigin(const TPoint3D ¢er, TPose3D &pose) const
3D Plane, represented by its equation
TVector3D director
Director vector.
void unitarize()
Unitarize normal vector.
double getAngle(const TPlane &p1, const TPlane &p2)
Computes the angle between two planes.
bool contains(const TPoint3D &point) const
Check whether a point is inside the line.
double distance(const TPoint3D &point) const
Distance to 3D point.
CMatrixDouble44 generateAxisBaseFromDirectionAndAxis(const mrpt::math::TVector3D &vec, uint8_t coord)
Creates a homogeneus matrix (4x4) such that the coordinate given (0 for x, 1 for y, 2 for z) corresponds to the provided vector.
Virtual base class for "archives": classes abstracting I/O streams.
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
mrpt::vision::TStereoCalibResults out
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &s, const CVectorFloat &a)
#define ASSERT_ABOVE_(__A, __B)
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
T norm() const
Point norm: |v| = sqrt(x^2+y^2+z^2)
bool contains(const TPoint3D &point) const
Check whether a point is contained into the plane.
TPlane()=default
Fast default constructor.
std::array< double, 4 > coefs
Plane coefficients, stored as an array: .
TVector3D getNormalVector() const
Get plane's normal vector.
3D line, represented by a base point and a director vector.