OpenLexocad  27.1
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 <vector>
25 
26 namespace Geom
27 {
28 class Mat;
29 class XYZ;
30 } // namespace Geom
31 
32 typedef std::vector<Geom::XYZ> COORDS;
33 
34 namespace Geom
35 {
42 
43 class LX_GEOM_EXPORT XYZ
44 {
45 public:
47  // //
48  // --------------------- BEGIN API --------------------- //
49  // //
50  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
51  // //
53 
54  // Methods PUBLIC
55  //
57  XYZ();
59  XYZ(const double X, const double Y, const double Z);
62  void setCoord(const double X, const double Y, const double Z);
63 
69  void setCoord(const int Index, const double Xi);
71  void setX(const double X);
73  void setY(const double Y);
75  void setZ(const double Z);
76 
83  double coord(const int Index) const;
84 
85  void coord(double& X, double& Y, double& Z) const;
87  double x() const;
89  double y() const;
91  double z() const;
93  double modulus() const;
95  double squareModulus() const;
96 
97 
104  bool isEqual(const XYZ& Other, const double Tolerance) const;
105 
109  void add(const XYZ& Other);
110  void operator+=(const XYZ& Other) { add(Other); }
111 
112 
116  XYZ added(const XYZ& Other) const;
117  XYZ operator+(const XYZ& Other) const { return added(Other); }
118 
119 
123  void cross(const XYZ& Right);
124  void operator^=(const XYZ& Right) { cross(Right); }
125 
126 
130  XYZ crossed(const XYZ& Right) const;
131  XYZ operator^(const XYZ& Right) const { return crossed(Right); }
132 
133 
136  double crossMagnitude(const XYZ& Right) const;
137 
140  double crossSquareMagnitude(const XYZ& Right) const;
143  void crossCross(const XYZ& Coord1, const XYZ& Coord2);
146  XYZ crossCrossed(const XYZ& Coord1, const XYZ& Coord2) const;
148  void divide(const double Scalar);
149  void operator/=(const double Scalar) { divide(Scalar); }
150 
152  XYZ divided(const double Scalar) const;
153  XYZ operator/(const double Scalar) const { return divided(Scalar); }
154 
156  double dot(const XYZ& Other) const;
157  double operator*(const XYZ& Other) const { return dot(Other); }
158 
160  double dotCross(const XYZ& Coord1, const XYZ& Coord2) const;
161 
165  void multiply(const double Scalar);
166  void operator*=(const double Scalar) { multiply(Scalar); }
167 
168 
172  void multiply(const XYZ& Other);
173  void operator*=(const XYZ& Other) { multiply(Other); }
174 
175  void multiply(const Geom::Mat& Matrix);
176  void operator*=(const Geom::Mat& Matrix) { multiply(Matrix); }
177 
178  // HPK TODO
180  /*void multiply(const Geom::Mat& Matrix) ;
181  void operator *=(const Geom::Mat& Matrix)
182  {
183  multiply(Matrix);
184  }
185  */
186 
187 
191  XYZ multiplied(const double Scalar) const;
192  XYZ operator*(const double Scalar) const { return multiplied(Scalar); }
193 
194 
195 
199  XYZ multiplied(const XYZ& Other) const;
201 
202  XYZ multiplied(const Geom::Mat& Matrix) const;
203  XYZ operator*(const Geom::Mat& Matrix) const { return multiplied(Matrix); }
204 
205 
209  void normalize();
210 
214  XYZ normalized() const;
215 
219  void reverse();
220 
224  XYZ reversed() const;
225 
229  void subtract(const XYZ& Right);
230  void operator-=(const XYZ& Right) { subtract(Right); }
231 
232 
236  XYZ subtracted(const XYZ& Right) const;
237  XYZ operator-(const XYZ& Right) const { return subtracted(Right); }
238 
239 
242  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2, const double A3, const XYZ& XYZ3, const XYZ& XYZ4);
243 
246  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2, const double A3, const XYZ& XYZ3);
247 
250  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2, const XYZ& XYZ3);
251 
254  void setLinearForm(const double A1, const XYZ& XYZ1, const double A2, const XYZ& XYZ2);
255 
258  void setLinearForm(const double A1, const XYZ& XYZ1, const XYZ& XYZ2);
259 
260  void setLinearForm(const XYZ& Left, const XYZ& Right);
261 
263  // //
264  // ---------------------- END API ---------------------- //
265  // //
267 
268  double& operator[](int i);
269  const double& operator[](int i) const;
270 
271  bool operator<(const XYZ& rhs) const;
272 
273 
274 private:
275  double _x;
276  double _y;
277  double _z;
278 };
279 
280 
281 typedef std::vector<XYZ> XYZ_Array;
282 } // namespace Geom
283 
284 inline Geom::XYZ operator*(const Geom::Mat& Matrix, const Geom::XYZ& Coord1)
285 {
286  return Coord1.multiplied(Matrix);
287 }
288 
289 inline Geom::XYZ operator*(const double Scalar, const Geom::XYZ& Coord1)
290 {
291  return Coord1.multiplied(Scalar);
292 }
Definition: Variant.h:60
X
Definition: Globals.h:29
XYZ operator-(const XYZ &Right) const
Definition: XYZ.h:237
XYZ operator/(const double Scalar) const
Definition: XYZ.h:153
void operator/=(const double Scalar)
Definition: XYZ.h:149
std::vector< Geom::XYZ > COORDS
Definition: XYZ.h:32
XYZ multiplied(const double Scalar) const
<me> = Matrix * <me>
Vector3f & operator *=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition: Matrix.h:351
std::vector< XYZ > XYZ_Array
Definition: XYZ.h:281
Definition: Mat.h:38
Geom::XYZ operator *(const Geom::Mat &Matrix, const Geom::XYZ &Coord1)
Definition: XYZ.h:284
Definition: XYZ.h:43
Y
Definition: Globals.h:29
XYZ operator+(const XYZ &Other) const
Definition: XYZ.h:117
void operator^=(const XYZ &Right)
Definition: XYZ.h:124
Z
Definition: Globals.h:29
XYZ operator^(const XYZ &Right) const
Definition: XYZ.h:131
void operator-=(const XYZ &Right)
Definition: XYZ.h:230
void operator+=(const XYZ &Other)
Definition: XYZ.h:110