OpenLexocad  27.0
XYZ.h
Go to the documentation of this file.
1 //
3 // Copyright(C) 2013-2016 OpenCascade [www.opencascade.org]
4 //
5 // This library is free software; you can redistribute it and / or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street,
18 // Fifth Floor, Boston, MA 02110 - 1301 USA
19 //
21 
22 #pragma once
23 
24 #include <Geom/GeomEnums.h>
25 #include <Geom/geom_defines.h>
26 
27 #include <vector>
28 
29 namespace Geom
30 {
31 class Mat;
32 class XYZ;
33 } // namespace Geom
34 
35 typedef std::vector<Geom::XYZ> COORDS;
36 
37 namespace Geom
38 {
45 
47 {
48 public:
50  // //
51  // --------------------- BEGIN API --------------------- //
52  // //
53  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
54  // //
56 
57  // Methods PUBLIC
58  //
60  XYZ();
62  XYZ(const double X, const double Y, const double Z);
65  void setCoord(const double X, const double Y, const double Z);
66 
72  void setCoord(const int Index, const double Xi);
74  void setX(const double X);
76  void setY(const double Y);
78  void setZ(const double Z);
79 
86  double coord(const int Index) const;
87 
88  void coord(double& X, double& Y, double& Z) const;
90  double x() const;
92  double y() const;
94  double z() const;
96  double modulus() const;
98  double squareModulus() const;
99 
100 
107  bool isEqual(const XYZ& Other, const double Tolerance) const;
108 
112  void add(const XYZ& Other);
113  void operator+=(const XYZ& Other) { add(Other); }
114 
115 
119  XYZ added(const XYZ& Other) const;
120  XYZ operator+(const XYZ& Other) const { return added(Other); }
121 
122 
126  void cross(const XYZ& Right);
127  void operator^=(const XYZ& Right) { cross(Right); }
128 
129 
133  XYZ crossed(const XYZ& Right) const;
134  XYZ operator^(const XYZ& Right) const { return crossed(Right); }
135 
136 
139  double crossMagnitude(const XYZ& Right) const;
140 
143  double crossSquareMagnitude(const XYZ& Right) const;
146  void crossCross(const XYZ& Coord1, const XYZ& Coord2);
149  XYZ crossCrossed(const XYZ& Coord1, const XYZ& Coord2) const;
151  void divide(const double Scalar);
152  void operator/=(const double Scalar) { divide(Scalar); }
153 
155  XYZ divided(const double Scalar) const;
156  XYZ operator/(const double Scalar) const { return divided(Scalar); }
157 
159  double dot(const XYZ& Other) const;
160  double operator*(const XYZ& Other) const { return dot(Other); }
161 
163  double dotCross(const XYZ& Coord1, const XYZ& Coord2) const;
164 
168  void multiply(const double Scalar);
169  void operator*=(const double Scalar) { multiply(Scalar); }
170 
171 
175  void multiply(const XYZ& Other);
176  void operator*=(const XYZ& Other) { multiply(Other); }
177 
178  void multiply(const Geom::Mat& Matrix);
179  void operator*=(const Geom::Mat& Matrix) { multiply(Matrix); }
180 
181  // HPK TODO
183  /*void multiply(const Geom::Mat& Matrix) ;
184  void operator *=(const Geom::Mat& Matrix)
185  {
186  multiply(Matrix);
187  }
188  */
189 
190 
194  XYZ multiplied(const double Scalar) const;
195  XYZ operator*(const double Scalar) const { return multiplied(Scalar); }
196 
197 
198 
202  XYZ multiplied(const XYZ& Other) const;
204 
205  XYZ multiplied(const Geom::Mat& Matrix) const;
206  XYZ operator*(const Geom::Mat& Matrix) const { return multiplied(Matrix); }
207 
208 
212  void normalize();
213 
217  XYZ normalized() const;
218 
222  void reverse();
223 
227  XYZ reversed() const;
228 
232  void subtract(const XYZ& Right);
233  void operator-=(const XYZ& Right) { subtract(Right); }
234 
235 
239  XYZ subtracted(const XYZ& Right) const;
240  XYZ operator-(const XYZ& Right) const { return subtracted(Right); }
241 
242 
245  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2, const double A3, const XYZ& XYZ3, const XYZ& XYZ4);
246 
249  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2, const double A3, const XYZ& XYZ3);
250 
253  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2, const XYZ& XYZ3);
254 
257  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2);
258 
261  void setLinearForm(const double A1, const XYZ& XYZ1, const XYZ& XYZ2);
262 
263  void setLinearForm(const XYZ& Left, const XYZ& Right);
264 
266  // //
267  // ---------------------- END API ---------------------- //
268  // //
270 
271  double& operator[](int i);
272  const double& operator[](int i) const;
273 
274  bool operator<(const XYZ& rhs) const;
275 
276 
277 private:
278  double _x;
279  double _y;
280  double _z;
281 };
282 
283 
284 typedef std::vector<XYZ> XYZ_Array;
285 } // namespace Geom
286 
287 inline Geom::XYZ operator*(const Geom::Mat& Matrix, const Geom::XYZ& Coord1)
288 {
289  return Coord1.multiplied(Matrix);
290 }
291 
292 inline Geom::XYZ operator*(const double Scalar, const Geom::XYZ& Coord1)
293 {
294  return Coord1.multiplied(Scalar);
295 }
Definition: Rotation.h:5
X
Definition: Globals.h:32
XYZ operator-(const XYZ &Right) const
Definition: XYZ.h:240
XYZ operator/(const double Scalar) const
Definition: XYZ.h:156
void operator/=(const double Scalar)
Definition: XYZ.h:152
std::vector< Geom::XYZ > COORDS
Definition: XYZ.h:35
XYZ multiplied(const double Scalar) const
<me> = Matrix * <me>
std::vector< XYZ > XYZ_Array
Definition: XYZ.h:284
Definition: Mat.h:41
Geom::XYZ operator *(const Geom::Mat &Matrix, const Geom::XYZ &Coord1)
Definition: XYZ.h:287
#define GEOM_EXPORT
Definition: geom_defines.h:8
Definition: XYZ.h:46
Y
Definition: Globals.h:32
XYZ operator+(const XYZ &Other) const
Definition: XYZ.h:120
void operator^=(const XYZ &Right)
Definition: XYZ.h:127
Z
Definition: Globals.h:32
XYZ operator^(const XYZ &Right) const
Definition: XYZ.h:134
void operator-=(const XYZ &Right)
Definition: XYZ.h:233
void operator+=(const XYZ &Other)
Definition: XYZ.h:113