MCL
A C++ library mirroring some of the most common Matlab functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
point.h
Go to the documentation of this file.
1 /*
2  MCL
3  Copyright (c) 2012-18, Enzo De Sena
4  All rights reserved.
5 
6  Authors: Enzo De Sena, enzodesena@gmail.com
7  */
8 
9 #ifndef MCL_POINT_H
10 #define MCL_POINT_H
11 
12 #include "mcltypes.h"
13 
14 namespace mcl {
15 
16 class Triplet {
17 public:
19  Triplet() noexcept;
20 
22  Triplet(Real x, Real y, Real z) noexcept;
23 
24  bool Equals(const Triplet& other_point) const noexcept;
25 
26  // Getter methods.
27  Real x() const noexcept { return x_; }
28  Real y() const noexcept { return y_; }
29  Real z() const noexcept { return z_; }
30 
31  void SetX(const Real value) noexcept { x_ = value; }
32  void SetY(const Real value) noexcept { y_ = value; }
33  void SetZ(const Real value) noexcept { z_ = value; }
34 
37  Real norm() const noexcept;
38 
40  Real theta() const noexcept;
41 
44  Real phi() const noexcept;
45 
47  void Normalize() noexcept;
48 
49 private:
50  Real x_;
51  Real y_;
52  Real z_;
53 };
54 
55 
56 
57 typedef Triplet Point;
58 
63 Point RotateAboutX(const Point&, Real) noexcept;
64 
69 Point RotateAboutY(const Point&, Real) noexcept;
70 
75 Point RotateAboutZ(const Point&, Real) noexcept;
76 
81 Point Rotate(const Point&, Real phi,
82  Real theta, Real psi) noexcept;
83 
84 Real DotProduct(Point, Point) noexcept;
85 Real Distance(Point, Point) noexcept;
86 Real Theta(Point, Point) noexcept;
87 Real Phi(Point, Point) noexcept;
88 Real AngleBetweenDirections(Real theta_a, Real phi_a,
89  Real theta_b, Real phi_b) noexcept;
90 Real AngleBetweenPoints(Point, Point) noexcept;
91 
96 Point PointOnLine(const Point point_a, const Point point_b,
97  const Real distance) noexcept;
98 
100 Point Sum(const Point point_a, const Point point_b) noexcept;
101 
103 Point Subtract(const Point point_a, const Point point_b) noexcept;
104 
109 Point Multiply(const Point point, const Real constant) noexcept;
110 
115 Point PointSpherical(Real r, Real theta, Real phi) noexcept;
116 
122 Point Projection(const Point& vector,
123  const Point& plane_normal_vector) noexcept;
124 
128 Point Normalized(Point point) noexcept;
129 
143 Point IntersectionPlaneLine(const Point& line_point,
144  const Point& line_direction,
145  const Point& plane_point,
146  const Point& plane_normal) noexcept;
147 
158 bool IntersectionPlaneLineExists(const Point& line_point,
159  const Point& line_direction,
160  const Point& plane_point,
161  const Point& plane_normal) noexcept;
162 
163 bool PointTest();
164 
165 
166 } // namespace mcl
167 
168 #endif