Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
vec.h
Go to the documentation of this file.
1#ifndef VEC_H
2#define VEC_H
3
4/*
5The base geometry file, determines class for geometrical conversions absref,
6vectors (vec), bases, points, and coordinate systems.
7Points differ from vectors in the conversions.
8Point is a vector denoting the position with respect to the center of
9coordinates. The vector is notation of direction. The vector is not
10changed at parallel translations of basis or system of coordinates,
11whereas the point is changed. Other explanations in my preprint
12"SpaceMetricLib, geometrical class library for detector modeling in HEP"
13
14
15Copyright (c) 2000 Igor B. Smirnov
16
17The file can be used, copied, modified, and distributed
18according to the terms of GNU Lesser General Public License version 2.1
19as published by the Free Software Foundation,
20and provided that the above copyright notice, this permission notice,
21and notices about any modifications of the original text
22appear in all copies and in supporting documentation.
23The file is provided "as is" without express or implied warranty.
24*/
25#include <string>
27
28#define pvecerror(string) \
29 mfunname(string); \
30 if (vecerror != 0) { \
31 mcerr << "vecerror is not zero, program is terminated\n" \
32 << " function detected error is " << string << '\n'; \
33 spexit(mcerr); \
34 }
35#define pvecerrorp(string) \
36 mfunnamep(string); \
37 if (vecerror != 0) { \
38 mcerr << "vecerror is not zero, program is terminated\n" \
39 << " function detected error is " << string << '\n'; \
40 spexit(mcerr); \
41 }
42// pvecerror is put after first line of function.
43// It makes up stack of functions names if FUNNAMESTACK is defined.
44// To work correctly stackline(string); should not be in any additional {}
45
47/* Introduces type vfloat which is used throughout the geometrical calculations
48instead of double. 'double' is meant to be replacable by 'float' for
49speeding up, but no consistent research was made to check that it really
50works in this way. So now vfloat is synonym of double.
51*/
52
53namespace Heed {
54
55extern int vecerror;
56
57class vec;
58class basis; // It is ortogonal basis
59class abssyscoor;
60class point;
61
62class absref_transmit;
63
64/// Abstract reference, base class for any geometrical vector object.
65/// Used for arranging of shift, turn and shange of coordinate system of
66/// vector objects. Four functions down(), up(), turn(), and shift() do that
67/// by calling of the same functions for any vector objects which are parts
68/// of this class.
69/// Address of parts lets known by virtual function get_components()
70/// which is reloaded in any derivative class.
71/// Class vec represents three-vectors and
72/// reloads the functions down(), up(), turn() with proper functions
73/// manipulating with three-vectors.
74/// Function shift() is also reloaded and does nothing for 3-vector vec,
75/// since it is assumed that 3-vector is characteristic of direction only,
76/// not point in space. We can not shift direction.
77/// For this reason, class point representing point in space
78/// reloads functions down and up again, and, of course, reloads shift.
79/// To make proper shift at switch to coordinate system with shifted center
80/// the point::down() and point::up() functions apply point::shift() function
81/// after or before vec::down() and vec::up().
82
83class absref {
84 public:
85 /// Destructor
86 virtual ~absref() {}
87 /// Convert numbering representation of object to basical system of fasc
88 virtual void down(const abssyscoor* fasc);
89 /// Convert numbering representation of objects to new system
90 virtual void up(const abssyscoor* fasc);
91 /// Turn around axis doing via center of coordinate system along dir.
92 virtual void turn(const vec& dir, vfloat angle);
93 virtual void shift(const vec& dir);
94
95 private:
96 virtual absref_transmit get_components();
97};
98
99/// Container for transmitting geometry transformations.
100/// Three methods of transmission (fast, slower and slowest) are available.
102 public:
103 absref_transmit() = default;
104 // For transmitting the members of the class, when
105 // their relative addresses are available.
106 absref_transmit(int fqaref, absref absref::** faref)
107 : qaref(fqaref), aref(faref) {}
108 absref_transmit(int fqaref_pointer, absref** faref_pointer)
109 : qaref_pointer(fqaref_pointer),
110 aref_pointer(faref_pointer) {}
111
112 absref_transmit(int fqaref, absref absref::** faref, int fqaref_pointer,
113 absref** faref_pointer)
114 : qaref(fqaref),
115 aref(faref),
116 qaref_pointer(fqaref_pointer),
117 aref_pointer(faref_pointer) {}
118 /// Copy constructor.
119 absref_transmit(const absref_transmit& f) = default;
120 /// Assignment operator.
122 /// Destructor.
123 virtual ~absref_transmit() {}
124
125 virtual void print(std::ostream& file, int l) const;
126 virtual absref_transmit* copy() const { return new absref_transmit(*this); }
127
128 /// Number of vector objects which are the members of the class
129 int qaref = 0;
130 /// Reference to address of array containing their relative addresses
131 /// as class members.
133
134 // When the relative addresses are not available, in particular
135 // when the component object is located in heap memory:
136 // Number of vector objects
138
139 // Reference to address of array containing addresses of objects.
141
142 // For any method of the object location the pointers can also be
143 // transmitted through the function get_other(int n)
144 // which receive the index of requested object and returns its address.
145 // For this the user should determine the class derived
146 // from absref_transmit. This is the slowest method of transmission.
147
148 /// Number of objects available though virtual function GetOther.
149 int qaref_other = 0;
150 /// This function is meant to be redefined in derived classes to
151 /// obtain additional address except those contained in aref and aref_pointer.
152 /// This default version always returns NULL.
153 virtual absref* get_other(int n);
154
155};
156
157#define ApplyAnyFunctionToVecElements(func) \
158 { \
159 auto aref_tran = get_components(); \
160 int q = aref_tran.qaref; \
161 for (int n = 0; n < q; n++) (this->*(aref_tran.aref[n])).func; \
162 q = aref_tran.qaref_pointer; \
163 for (int n = 0; n < q; n++) aref_tran.aref_pointer[n]->func; \
164 q = aref_tran.qaref_other; \
165 for (int n = 0; n < q; n++) { \
166 absref* ar = aref_tran.get_other(n); \
167 if (!ar) break; \
168 ar->func; \
169 } \
170 }
171
172/// Vector.
173/// Each vector is presented by three components and corresponds to some basis.
174/// // The components are a projection of the vector to unit basis vectors.
175/// If bas==NULL then it is the primary basis.
176/// So the concept of vector is more primary concept with comparison of
177/// basis, since one can not postulate basis while vectors do not exist.
178
179class vec : public absref {
180 public:
181 /// Constructor.
182 vec(vfloat xx, vfloat yy, vfloat zz) {
183 x = xx;
184 y = yy;
185 z = zz;
186 }
187 /// Default constructor.
188 vec() = default;
189 /// Destructor
190 virtual ~vec() {}
191
192 vfloat x = 0.;
193 vfloat y = 0.;
194 vfloat z = 0.;
195
196 vfloat length() const { return sqrt(x * x + y * y + z * z); }
197 vfloat length2() const { return x * x + y * y + z * z; }
198
199 vec down_new(const basis* fabas);
200 vec up_new(const basis* fabas_new);
201
202 void down(const basis* fabas);
203 void up(const basis* fabas_new);
204
205 vec down_new(const abssyscoor* fasc);
206 vec up_new(const abssyscoor* fasc);
207
208 void down(const abssyscoor* fasc) override;
209 void up(const abssyscoor* fasc) override;
210
211 /// Make new turned vector and leave this one unchanged.
212 vec turn_new(const vec& dir, vfloat angle);
213 /// Turn this vector
214 void turn(const vec& dir, vfloat angle) override;
215 void shift(const vec& dir) override;
216
217 /// Generate random unit vector in plane perpendicular to z-axis.
218 void random_round_vec();
219 /// Generate random unit vector in any direction in conus
220 /// with symmetry axis along z-axis and with angle theta (radian).
221 void random_conic_vec(double theta);
222 // Generate random unit vector in any direction in 3D space.
223 void random_sfer_vec();
224
225 friend vec operator*(const vec& v, vfloat p) {
226 return vec(v.x * p, v.y * p, v.z * p);
227 }
228 friend vec operator*=(vec& v, vfloat p) {
229 v = v * p;
230 return v;
231 }
232 friend vec operator*(vfloat p, const vec& v) {
233 return vec(v.x * p, v.y * p, v.z * p);
234 }
235 vec operator/(vfloat p) const { return vec(x / p, y / p, z / p); }
236 friend vec operator/=(vec& v, vfloat p) {
237 v = v / p;
238 return v;
239 }
240 friend vec operator+(const vec& r1, const vec& r2) {
241 return vec(r1.x + r2.x, r1.y + r2.y, r1.z + r2.z);
242 }
243 friend vec& operator+=(vec& r1, const vec& r2) {
244 r1 = r1 + r2;
245 return r1;
246 }
247 friend vec operator-(const vec& r1, const vec& r2) {
248 return vec(r1.x - r2.x, r1.y - r2.y, r1.z - r2.z);
249 }
250 friend vec operator-=(vec& r1, const vec& r2) {
251 r1 = r1 - r2;
252 return r1;
253 }
254 friend vec operator-(const vec& r) { return vec(-r.x, -r.y, -r.z); }
255 friend vfloat operator*(const vec& r1, const vec& r2) {
256 return r1.x * r2.x + r1.y * r2.y + r1.z * r2.z;
257 }
258 /// Vector product.
259 friend vec operator||(const vec& r1, const vec& r2) {
260 return vec(r1.y * r2.z - r1.z * r2.y, r1.z * r2.x - r1.x * r2.z,
261 r1.x * r2.y - r1.y * r2.x);
262 }
263 /// Return 1 if precisely the same vectors and 0 otherwise.
264 friend inline int operator==(const vec& r1, const vec& r2);
265 /// Return 0 if precisely the same vectors and 1 otherwise.
266 friend inline int operator!=(const vec& r1, const vec& r2);
267
268 /// Return true if two vectors are approximately the same.
269 friend inline bool apeq(const vec& r1, const vec& r2, vfloat prec);
270
271 friend inline vec unit_vec(const vec& v);
272 // cosinus of angle between vectors
273 // If one of vectors has zero length, it makes vecerror=1 and returns 0.
274 friend vfloat cos2vec(const vec& r1, const vec& r2);
275 // angle between vectors, in interval [0, M_PI]
276 // If one of vectors has zero length, it makes vecerror=1.
277 friend vfloat ang2vec(const vec& r1, const vec& r2);
278 friend vec project_to_plane(const vec& r, const vec& normal);
279 // angle between projections of 2 vectors on plane normal to vector normal
280 // in interval [0, 2*M_PI]
281 // If one of vectors has zero length, it makes vecerror=1.
282 friend vfloat ang2projvec(const vec& r1, const vec& r2, const vec& normal);
283 // sinus of angle between vectors, 0 or positive.
284 // If one of vectors has zero length, it makes vecerror=1.
285 friend vfloat sin2vec(const vec& r1, const vec& r2);
286
287 /// Check whether two vectors are parallel, or anti-parallel.
288 /// Returns: 1 - parallel, -1 - antiparallel, 0 not parallel.
289 /// Also returns 0 if one or both vectors have zero length.
290 /// Thus, if angle between vectors < prec, they are parallel.
291 friend inline int check_par(const vec& r1, const vec& r2, vfloat prec);
292
293 /// Check whether two vectors are perpendicular.
294 /// Returns: 1 perpendicular, 0 not perpendicular.
295 /// Also returns 0 if one or both vectors have zero length.
296 /// Thus, if angle between vectors
297 /// a > 0.5 * M_PI - max(prec, vprecision) and
298 /// a < 0.5 * M_PI + max(prec, vprecision), they are perpendicular.
299 friend inline int check_perp(const vec& r1, const vec& r2, vfloat prec);
300 friend inline vec switch_xyz(const vec&); // don't change the vector itself
301
302};
303std::ostream& operator<<(std::ostream& file, const vec& v);
304
305extern vec dex; // unit vector by x
306extern vec dey; // unit vector by y
307extern vec dez; // unit vector by z
308extern vec dv0; // zero vector
309
310#include "wcpplib/geometry/vec.ic"
311
312/// Basis.
313class basis : public absref {
314 protected:
315 /// Unit vectors giving directions of Cartesian axes.
316 /// Supposed to be perpendicular, therefore not public.
318
319 virtual absref_transmit get_components() override;
320
321 static absref absref::*aref[3];
322
323 public:
324 std::string name;
325
326 public:
327 vec Gex() const { return ex; }
328 vec Gey() const { return ey; }
329 vec Gez() const { return ez; }
330
331 /// Change ex=ez; ey=ex; ez=ey.
332 basis switch_xyz() const;
333
334 /// Nominal basis.
335 basis();
336 /// Nominal basis.
337 basis(const std::string& pname);
338 /// Longitudinal basis.
339 /// z-axis is parallel to p.
340 /// y-axis is vector product of z_new and z_old
341 /// x-axis is vector product of y_new and z_new
342 /// If p is parallel to z_old, the copy of old basis is created.
343 /// If p is anti-parallel to z_old, the inverted copy of old basis is created.
344 basis(const vec& p, const std::string& fname);
345
346 /// More sophisticated basis.
347 /// ez is parallel to p, ez=unit_vec(p)
348 /// ey is perpendicular to plane which have p and c, ey=unit_vec(ez||c)
349 /// ex is vector product of y and z, ex=ey||ez
350 /// If p is parallel to c, or p is anti-parallel to c, vecerror=1
351 /// if(length(p)==0||length(c)==0)) vecerror=1;
352 basis(const vec& p, const vec& c, const std::string& pname);
353
354 /// Same basis with other name, useful for later turning.
355 basis(const basis& pb, const std::string& pname);
356 /// Direct definitions of basis by three perpendicular unit-length vectors.
357 basis(const vec& pex, const vec& pey, const vec& pez, const std::string& pname);
358
359 friend std::ostream& operator<<(std::ostream& file, const basis& b);
360 virtual basis* copy() const { return new basis(*this); }
361 virtual void print(std::ostream& file, int l) const;
362 virtual ~basis() {}
363};
364extern std::ostream& operator<<(std::ostream& file, const basis& b);
365
366/// Point.
367
368class point : public absref {
369 public:
371
372 private:
373 absref_transmit get_components() override;
374 static absref absref::* aref;
375
376 public:
377 void down(const abssyscoor* fasc) override;
378 void up(const abssyscoor* fasc) override;
379 void shift(const vec& dir) override {
380 v += dir;
381 }
382 /// Default constructor (coordinates are not initialised).
383 point() : v() {}
384 /// Constructor from vector.
385 point(const vec& fv) : v(fv) {}
386 /// Constructor from coordinates.
387 point(const vfloat fex, const vfloat fey, const vfloat fez)
388 : v(fex, fey, fez) {}
389 /// Copy constructor.
390 point(const point& p) : v(p.v) {}
391 /// Assignment operator.
392 point& operator=(const point& fp) {
393 v = fp.v;
394 return *this;
395 }
396 vec operator-(const point& pp) const { return v - pp.v; }
397 // creates vector from pp to p
398 point operator+(const vec& fv) const { return point(v + fv); }
399 friend int operator==(const point& p1, const point& p2) {
400 return p1.v == p2.v ? 1 : 0;
401 }
402 friend int operator!=(const point& p1, const point& p2) {
403 return p1.v != p2.v ? 1 : 0;
404 }
405 friend bool apeq(const point& p1, const point& p2, vfloat prec) {
406 return apeq(p1.v, p2.v, prec);
407 }
408 friend std::ostream& operator<<(std::ostream& file, const point& p);
409 virtual point* copy() const { return new point(*this); }
410 virtual void print(std::ostream& file, int l) const;
411 virtual ~point() {}
412};
413std::ostream& operator<<(std::ostream& file, const point& p);
414
415/// Coordinate system (centre, basis and mother coordinate system).
416/// Take care: c.abas must be equal to abas->ex.abas.
417/// If asc==NULL and abs(c)==0 than it is primary system of coordinate
418/// and therefore c.abas and abas->ex.abas must be zero,
419/// baz may be zero or pointer to unit basis.
420
421#define vec_syscoor_index 0
423 public:
424 std::string name = "none";
425 virtual const point* Gapiv() const = 0;
426 virtual const basis* Gabas() const = 0;
427 abssyscoor() = default;
428 abssyscoor(char* fname) : name(fname) {}
429 abssyscoor(const std::string& fname) : name(fname) {}
430 virtual void print(std::ostream& file, int l) const;
431
432 virtual ~abssyscoor() {}
433};
434extern std::ostream& operator<<(std::ostream& file, const abssyscoor& s);
435
436class fixsyscoor : public absref, public abssyscoor {
437 public:
438 const point* Gapiv() const override { return &piv; }
439 const basis* Gabas() const override { return &bas; }
440 void Ppiv(const point& fpiv);
441 void Pbas(const basis& fbas);
442 // nominal system
443 fixsyscoor() = default;
444 fixsyscoor(char* fname) : abssyscoor(fname) {}
445 fixsyscoor(const std::string& fname) : abssyscoor(fname) {}
446 fixsyscoor(const point& fpiv, const basis& fbas, const std::string& fname)
447 : abssyscoor(fname), piv(fpiv), bas(fbas) {}
448 fixsyscoor(const point* const fapiv, const basis* const fabas,
449 const std::string& fname)
450 : abssyscoor(fname),
451 piv((fapiv != NULL) ? (*fapiv) : point()),
452 bas((fabas != NULL) ? (*fabas) : basis()) {}
454 : abssyscoor(f),
455 piv((f.Gapiv() != NULL) ? (*(f.Gapiv())) : point()),
456 bas((f.Gabas() != NULL) ? (*(f.Gabas())) : basis()) {}
457 void print(std::ostream& file, int l) const override;
458 fixsyscoor* copy() const { return new fixsyscoor(*this); }
459 virtual ~fixsyscoor() {}
460
461 protected:
463 static absref absref::* aref[2];
464
465 private:
466 point piv;
467 basis bas;
468};
469extern std::ostream& operator<<(std::ostream& file, const fixsyscoor& s);
470}
471
472#endif
absref_transmit & operator=(const absref_transmit &f)=default
Assignment operator.
int qaref_other
Number of objects available though virtual function GetOther.
Definition: vec.h:149
absref_transmit(int fqaref, absref absref::**faref, int fqaref_pointer, absref **faref_pointer)
Definition: vec.h:112
virtual void print(std::ostream &file, int l) const
Definition: vec.cpp:31
absref ** aref_pointer
Definition: vec.h:140
absref_transmit(int fqaref_pointer, absref **faref_pointer)
Definition: vec.h:108
virtual absref * get_other(int n)
Definition: vec.cpp:39
int qaref
Number of vector objects which are the members of the class.
Definition: vec.h:129
absref_transmit(int fqaref, absref absref::**faref)
Definition: vec.h:106
absref absref::** aref
Definition: vec.h:132
virtual absref_transmit * copy() const
Definition: vec.h:126
virtual ~absref_transmit()
Destructor.
Definition: vec.h:123
absref_transmit(const absref_transmit &f)=default
Copy constructor.
virtual void up(const abssyscoor *fasc)
Convert numbering representation of objects to new system.
Definition: vec.cpp:48
virtual void shift(const vec &dir)
Definition: vec.cpp:57
virtual void down(const abssyscoor *fasc)
Convert numbering representation of object to basical system of fasc.
Definition: vec.cpp:43
virtual ~absref()
Destructor.
Definition: vec.h:86
virtual void turn(const vec &dir, vfloat angle)
Turn around axis doing via center of coordinate system along dir.
Definition: vec.cpp:53
virtual void print(std::ostream &file, int l) const
Definition: vec.cpp:439
virtual ~abssyscoor()
Definition: vec.h:432
abssyscoor()=default
virtual const point * Gapiv() const =0
abssyscoor(const std::string &fname)
Definition: vec.h:429
virtual const basis * Gabas() const =0
std::string name
Definition: vec.h:424
abssyscoor(char *fname)
Definition: vec.h:428
Basis.
Definition: vec.h:313
virtual basis * copy() const
Definition: vec.h:360
virtual absref_transmit get_components() override
Definition: vec.cpp:272
vec ez
Definition: vec.h:317
virtual ~basis()
Definition: vec.h:362
basis()
Nominal basis.
Definition: vec.cpp:281
std::string name
Definition: vec.h:324
vec Gez() const
Definition: vec.h:329
basis switch_xyz() const
Change ex=ez; ey=ex; ez=ey.
Definition: vec.cpp:276
friend std::ostream & operator<<(std::ostream &file, const basis &b)
Definition: vec.cpp:389
vec ex
Definition: vec.h:317
vec Gey() const
Definition: vec.h:328
static absref absref::* aref[3]
Definition: vec.h:321
vec ey
Definition: vec.h:317
vec Gex() const
Definition: vec.h:327
virtual void print(std::ostream &file, int l) const
Definition: vec.cpp:387
fixsyscoor(char *fname)
Definition: vec.h:444
const basis * Gabas() const override
Definition: vec.h:439
fixsyscoor()=default
void Ppiv(const point &fpiv)
Definition: vec.cpp:477
static absref absref::* aref[2]
Definition: vec.h:463
fixsyscoor * copy() const
Definition: vec.h:458
absref_transmit get_components() override
Definition: vec.cpp:473
void Pbas(const basis &fbas)
Definition: vec.cpp:478
void print(std::ostream &file, int l) const override
Definition: vec.cpp:480
fixsyscoor(const point &fpiv, const basis &fbas, const std::string &fname)
Definition: vec.h:446
fixsyscoor(const point *const fapiv, const basis *const fabas, const std::string &fname)
Definition: vec.h:448
virtual ~fixsyscoor()
Definition: vec.h:459
fixsyscoor(const abssyscoor &f)
Definition: vec.h:453
fixsyscoor(const std::string &fname)
Definition: vec.h:445
const point * Gapiv() const override
Definition: vec.h:438
Point.
Definition: vec.h:368
virtual ~point()
Definition: vec.h:411
void shift(const vec &dir) override
Definition: vec.h:379
point()
Default constructor (coordinates are not initialised).
Definition: vec.h:383
point operator+(const vec &fv) const
Definition: vec.h:398
friend int operator!=(const point &p1, const point &p2)
Definition: vec.h:402
friend bool apeq(const point &p1, const point &p2, vfloat prec)
Definition: vec.h:405
point & operator=(const point &fp)
Assignment operator.
Definition: vec.h:392
point(const vfloat fex, const vfloat fey, const vfloat fez)
Constructor from coordinates.
Definition: vec.h:387
void up(const abssyscoor *fasc) override
Convert numbering representation of objects to new system.
Definition: vec.cpp:422
vec operator-(const point &pp) const
Definition: vec.h:396
void down(const abssyscoor *fasc) override
Convert numbering representation of object to basical system of fasc.
Definition: vec.cpp:418
friend int operator==(const point &p1, const point &p2)
Definition: vec.h:399
point(const point &p)
Copy constructor.
Definition: vec.h:390
vec v
Definition: vec.h:370
point(const vec &fv)
Constructor from vector.
Definition: vec.h:385
virtual point * copy() const
Definition: vec.h:409
friend std::ostream & operator<<(std::ostream &file, const point &p)
Definition: vec.cpp:429
virtual void print(std::ostream &file, int l) const
Definition: vec.cpp:427
Definition: vec.h:179
void turn(const vec &dir, vfloat angle) override
Turn this vector.
Definition: vec.cpp:216
vec up_new(const basis *fabas_new)
Definition: vec.cpp:170
void shift(const vec &dir) override
Definition: vec.cpp:220
friend vec operator*(const vec &v, vfloat p)
Definition: vec.h:225
friend int check_perp(const vec &r1, const vec &r2, vfloat prec)
friend vec operator+(const vec &r1, const vec &r2)
Definition: vec.h:240
friend vfloat ang2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:89
vec turn_new(const vec &dir, vfloat angle)
Make new turned vector and leave this one unchanged.
Definition: vec.cpp:192
friend vec operator-(const vec &r1, const vec &r2)
Definition: vec.h:247
vfloat x
Definition: vec.h:192
friend vfloat operator*(const vec &r1, const vec &r2)
Definition: vec.h:255
friend bool apeq(const vec &r1, const vec &r2, vfloat prec)
Return true if two vectors are approximately the same.
friend vec operator/=(vec &v, vfloat p)
Definition: vec.h:236
friend vec operator||(const vec &r1, const vec &r2)
Vector product.
Definition: vec.h:259
vfloat length() const
Definition: vec.h:196
vfloat z
Definition: vec.h:194
friend vec operator-=(vec &r1, const vec &r2)
Definition: vec.h:250
vec operator/(vfloat p) const
Definition: vec.h:235
void up(const basis *fabas_new)
Definition: vec.cpp:190
friend int operator==(const vec &r1, const vec &r2)
Return 1 if precisely the same vectors and 0 otherwise.
void random_conic_vec(double theta)
Definition: vec.cpp:236
friend vec & operator+=(vec &r1, const vec &r2)
Definition: vec.h:243
friend vec switch_xyz(const vec &)
friend vec operator-(const vec &r)
Definition: vec.h:254
friend vec operator*=(vec &v, vfloat p)
Definition: vec.h:228
friend int check_par(const vec &r1, const vec &r2, vfloat prec)
friend vec operator*(vfloat p, const vec &v)
Definition: vec.h:232
virtual ~vec()
Destructor.
Definition: vec.h:190
vec(vfloat xx, vfloat yy, vfloat zz)
Constructor.
Definition: vec.h:182
friend vec unit_vec(const vec &v)
friend vec project_to_plane(const vec &r, const vec &normal)
Definition: vec.cpp:124
friend vfloat cos2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:66
vec()=default
Default constructor.
vfloat length2() const
Definition: vec.h:197
friend int operator!=(const vec &r1, const vec &r2)
Return 0 if precisely the same vectors and 1 otherwise.
friend vfloat ang2projvec(const vec &r1, const vec &r2, const vec &normal)
Definition: vec.cpp:136
friend vfloat sin2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:107
void down(const basis *fabas)
Definition: vec.cpp:168
void random_sfer_vec()
Definition: vec.cpp:244
void random_round_vec()
Generate random unit vector in plane perpendicular to z-axis.
Definition: vec.cpp:229
vec down_new(const basis *fabas)
Definition: vec.cpp:156
vfloat y
Definition: vec.h:193
Definition: BGMesh.cpp:6
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37
vec dv0(0, 0, 0)
Definition: vec.h:308
int vecerror
Definition: vec.cpp:29
vec dex(1, 0, 0)
Definition: vec.h:305
vec dez(0, 0, 1)
Definition: vec.h:307
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
vec dey(0, 1, 0)
Definition: vec.h:306
double vfloat
Definition: vfloat.h:16