MRPT  1.9.9
TLine3D.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10
11 #include <mrpt/math/TPoint3D.h>
12 #include <array>
13
14 namespace mrpt::math
15 {
16 /** 3D line, represented by a base point and a director vector.
17  * \sa TLine2D,TSegment3D,TPlane,TPolygon3D,TPoint3D
18  */
19 struct TLine3D
20 {
21  public:
22  /** Base point */
24  /** Director vector */
25  std::array<double, 3> director{{.0, .0, .0}};
26  /** Check whether a point is inside the line */
27  bool contains(const TPoint3D& point) const;
28  /**
29  * Distance between the line and a point.
30  */
31  double distance(const TPoint3D& point) const;
32  /**
33  * Unitarize director vector.
34  */
35  void unitarize();
36  /** Get director vector */
37  void getDirectorVector(double (&vector)[3]) const
38  {
39  for (size_t i = 0; i < 3; i++) vector[i] = director[i];
40  }
41  /** Get director vector */
43  {
44  TVector3D v;
45  for (int i = 0; i < 3; i++) v[i] = director[i];
46  return v;
47  }
48  /**
49  * Unitarize and then get director vector.
50  */
51  void getUnitaryDirectorVector(double (&vector)[3])
52  {
53  unitarize();
54  getDirectorVector(vector);
55  }
56  /**
57  * Project into 2D space, discarding the Z coordinate.
58  * \throw std::logic_error if the line's director vector is orthogonal to
59  * the XY plane.
60  */
61  void generate2DObject(TLine2D& l) const;
62  /**
63  * Constructor from two points, through which the line will pass.
64  * \throw std::logic_error if both points are the same.
65  */
66  TLine3D(const TPoint3D& p1, const TPoint3D& p2);
67  /**
68  * Constructor from 3D segment.
69  */
70  explicit TLine3D(const TSegment3D& s);
71  /**
72  * Fast default constructor. Initializes to garbage.
73  */
74  TLine3D() = default;
75  /** Constructor from 2D object. Zeroes the z. */
76  explicit TLine3D(const TLine2D& l);
77 };
78
83
84 } // namespace mrpt::math
85
86 namespace mrpt::typemeta
87 {
88 // Specialization must occur in the same namespace
90 } // namespace mrpt::typemeta
double distance(const TPoint3D &point) const
Distance between the line and a point.
TPoint3D pBase
Base point.
Definition: TLine3D.h:23
GLdouble s
Definition: glext.h:3682
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrixD::Ptr &pObj)
void getUnitaryDirectorVector(double(&vector)[3])
Unitarize and then get director vector.
Definition: TLine3D.h:51
void generate2DObject(TLine2D &l) const
Project into 2D space, discarding the Z coordinate.
bool contains(const TPoint3D &point) const
Check whether a point is inside the line.
This base provides a set of functions for maths stuff.
3D segment, consisting of two points.
Definition: TSegment3D.h:21
std::array< double, 3 > director
Director vector.
Definition: TLine3D.h:25
void getDirectorVector(double(&vector)[3]) const
Get director vector.
Definition: TLine3D.h:37
#define MRPT_DECLARE_TTYPENAME_NO_NAMESPACE(_TYPE, __NS)
Declares a typename to be "type" (without the NS prefix)
Definition: TTypeName.h:128
void unitarize()
Unitarize director vector.
const GLdouble * v
Definition: glext.h:3684
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::vision::TStereoCalibResults out
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &s, const CVectorFloat &a)
Definition: math.cpp:627
TVector3D getDirectorVector() const
Get director vector.
Definition: TLine3D.h:42
GLuint in
Definition: glext.h:7391
TLine3D()=default
Fast default constructor.
Lightweight 3D point.
Definition: TPoint3D.h:90
3D line, represented by a base point and a director vector.
Definition: TLine3D.h:19
2D line without bounds, represented by its equation .
Definition: TLine2D.h:19

 Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: cb8dd5fc8 Sat Dec 7 21:55:39 2019 +0100 at sáb dic 7 22:00:13 CET 2019