23 #include "mirtk/Object.h" 25 #include "mirtk/Vector3.h" 26 #include "mirtk/Point.h" 27 #include "mirtk/PointSet.h" 44 mirtkObjectMacro(
Plane);
50 mirtkPublicAttributeMacro(
double, Offset);
53 mirtkReadOnlyAttributeMacro(
Vector3, Tangent1);
56 mirtkReadOnlyAttributeMacro(
Vector3, Tangent2);
67 mirtkReadOnlyAttributeMacro(
Point, Origin);
70 void CopyAttributes(
const Plane &);
97 Plane(
double n[3],
double b);
105 Plane(
double nx,
double ny,
double nz,
double b);
129 void Normal(
double nx,
double ny,
double nz);
157 double Evaluate(
const double p[3])
const;
166 double Evaluate(
double x,
double y,
double z)
const;
180 double Distance(
const double p[3])
const;
189 double Distance(
double x,
double y,
double z)
const;
199 void Project(
const Point &p,
double &u,
double &v)
const;
206 void Project(
const double p[3],
double &u,
double &v)
const;
215 void Project(
double x,
double y,
double z,
double &u,
double &v)
const;
240 _Tangent1(1.0, .0, .0),
241 _Tangent2(.0, 1.0, .0),
242 _Normal (.0, .0, 1.0),
261 _Normal(n[0], n[1], n[2])
278 inline void Plane::CopyAttributes(
const Plane &other)
280 _Offset = other._Offset;
281 _Normal = other._Normal;
282 _Tangent1 = other._Tangent1;
283 _Tangent2 = other._Tangent2;
284 _Origin = other._Origin;
290 CopyAttributes(other);
296 if (
this != &other) {
297 Object::operator =(other);
298 CopyAttributes(other);
343 return p.
_x * _Normal[0] + p.
_y * _Normal[1] + p.
_z * _Normal[2] - _Offset;
349 return p[0] * _Normal[0] + p[1] * _Normal[1] + p[2] * _Normal[2] - _Offset;
355 return x * _Normal[0] + y * _Normal[1] + z * _Normal[2] - _Offset;
383 Vector3 d(p.
_x - _Origin._x, p.
_y - _Origin._y, p.
_z - _Origin._z);
384 u = _Tangent1.Dot(d);
385 v = _Tangent2.Dot(d);
391 Vector3 d(p[0] - _Origin._x, p[1] - _Origin._y, p[2] - _Origin._z);
392 u = _Tangent1.Dot(d);
393 v = _Tangent2.Dot(d);
397 inline void Plane::Project(
double x,
double y,
double z,
double &u,
double &v)
const 399 Vector3 d(x - _Origin._x, y - _Origin._y, z - _Origin._z);
400 u = _Tangent1.Dot(d);
401 v = _Tangent2.Dot(d);
417 #endif // MIRTK_Plane_H
Plane()
Default constructor.
double Distance(const Point &p) const
double _x
x coordinate of Point
void Project(const Point &p, double &u, double &v) const
void UpdateOrigin()
Update origin after change of plane normal.
virtual ~Plane()
Destructor.
ostream & Print(ostream &os, Indent=0) const
Print plane equation.
double Fit(const PointSet &points)
double Evaluate(const Point &p) const
Plane & operator=(const Plane &)
Assignment operator.
void Normal(const Vector3 &n)
Set normal vector.
double _z
z coordinate of Point
double _y
y coordinate of Point
void UpdateTangents()
Update tangent vectors after change of plane normal.