Garfield++ 3.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:
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
119 absref_transmit(const absref_transmit& f) { *this = f; }
120 /// Destructor
121 virtual ~absref_transmit() {}
122
123 virtual void print(std::ostream& file, int l) const;
124 virtual absref_transmit* copy() const { return new absref_transmit(*this); }
125
126 /// Number of vector objects which are the members of the class
127 int qaref = 0;
128 /// Reference to address of array containing their relative addresses
129 /// as class members.
131
132 // When the relative addresses are not available, in particular
133 // when the component object is located in heap memory:
134 // Number of vector objects
136
137 // Reference to address of array containing addresses of objects.
139
140 // For any method of the object location the pointers can also be
141 // transmitted through the function get_other(int n)
142 // which receive the index of requested object and returns its address.
143 // For this the user should determine the class derived
144 // from absref_transmit. This is the slowest method of transmission.
145
146 /// Number of objects available though virtual function GetOther.
147 int qaref_other = 0;
148 /// This function is meant to be redefined in derived classes to
149 /// obtain additional address except those contained in aref and aref_pointer.
150 /// This default version always returns NULL.
151 virtual absref* get_other(int n);
152
153};
154
155#define ApplyAnyFunctionToVecElements(func) \
156 { \
157 auto aref_tran = get_components(); \
158 int q = aref_tran.qaref; \
159 for (int n = 0; n < q; n++) (this->*(aref_tran.aref[n])).func; \
160 q = aref_tran.qaref_pointer; \
161 for (int n = 0; n < q; n++) aref_tran.aref_pointer[n]->func; \
162 q = aref_tran.qaref_other; \
163 for (int n = 0; n < q; n++) { \
164 absref* ar = aref_tran.get_other(n); \
165 if (!ar) break; \
166 ar->func; \
167 } \
168 }
169
170/// Vector.
171/// Each vector is presented by three components and corresponds to some basis.
172/// // The components are a projection of the vector to unit basis vectors.
173/// If bas==NULL then it is the primary basis.
174/// So the concept of vector is more primary concept with comparison of
175/// basis, since one can not postulate basis while vectors do not exist.
176
177class vec : public absref {
178 public:
179 /// Constructor.
180 vec(vfloat xx, vfloat yy, vfloat zz) {
181 x = xx;
182 y = yy;
183 z = zz;
184 }
185 /// Default constructor.
186 vec() = default;
187 /// Destructor
188 virtual ~vec() {}
189
190 vfloat x = 0.;
191 vfloat y = 0.;
192 vfloat z = 0.;
193
194 vfloat length() const { return sqrt(x * x + y * y + z * z); }
195 vfloat length2() const { return x * x + y * y + z * z; }
196
197 vec down_new(const basis* fabas);
198 vec up_new(const basis* fabas_new);
199
200 void down(const basis* fabas);
201 void up(const basis* fabas_new);
202
203 vec down_new(const abssyscoor* fasc);
204 vec up_new(const abssyscoor* fasc);
205
206 void down(const abssyscoor* fasc) override;
207 void up(const abssyscoor* fasc) override;
208
209 /// Make new turned vector and leave this one unchanged.
210 vec turn_new(const vec& dir, vfloat angle);
211 /// Turn this vector
212 void turn(const vec& dir, vfloat angle) override;
213 void shift(const vec& dir) override;
214
215 /// Generate random unit vector in plane perpendicular to z-axis.
216 void random_round_vec();
217 /// Generate random unit vector in any direction in conus
218 /// with symmetry axis along z-axis and with angle theta (radian).
219 void random_conic_vec(double theta);
220 // Generate random unit vector in any direction in 3D space.
221 void random_sfer_vec();
222
223 friend vec operator*(const vec& v, vfloat p) {
224 return vec(v.x * p, v.y * p, v.z * p);
225 }
226 friend vec operator*=(vec& v, vfloat p) {
227 v = v * p;
228 return v;
229 }
230 friend vec operator*(vfloat p, const vec& v) {
231 return vec(v.x * p, v.y * p, v.z * p);
232 }
233 vec operator/(vfloat p) const { return vec(x / p, y / p, z / p); }
234 friend vec operator/=(vec& v, vfloat p) {
235 v = v / p;
236 return v;
237 }
238 friend vec operator+(const vec& r1, const vec& r2) {
239 return vec(r1.x + r2.x, r1.y + r2.y, r1.z + r2.z);
240 }
241 friend vec& operator+=(vec& r1, const vec& r2) {
242 r1 = r1 + r2;
243 return r1;
244 }
245 friend vec operator-(const vec& r1, const vec& r2) {
246 return vec(r1.x - r2.x, r1.y - r2.y, r1.z - r2.z);
247 }
248 friend vec operator-=(vec& r1, const vec& r2) {
249 r1 = r1 - r2;
250 return r1;
251 }
252 friend vec operator-(const vec& r) { return vec(-r.x, -r.y, -r.z); }
253 friend vfloat operator*(const vec& r1, const vec& r2) {
254 return r1.x * r2.x + r1.y * r2.y + r1.z * r2.z;
255 }
256 /// Vector product.
257 friend vec operator||(const vec& r1, const vec& r2) {
258 return vec(r1.y * r2.z - r1.z * r2.y, r1.z * r2.x - r1.x * r2.z,
259 r1.x * r2.y - r1.y * r2.x);
260 }
261 /// Return 1 if precisely the same vectors and 0 otherwise.
262 friend inline int operator==(const vec& r1, const vec& r2);
263 /// Return 0 if precisely the same vectors and 1 otherwise.
264 friend inline int operator!=(const vec& r1, const vec& r2);
265
266 /// Return true if two vectors are approximately the same.
267 friend inline bool apeq(const vec& r1, const vec& r2, vfloat prec);
268
269 friend inline vec unit_vec(const vec& v);
270 // cosinus of angle between vectors
271 // If one of vectors has zero length, it makes vecerror=1 and returns 0.
272 friend vfloat cos2vec(const vec& r1, const vec& r2);
273 // angle between vectors, in interval [0, M_PI]
274 // If one of vectors has zero length, it makes vecerror=1.
275 friend vfloat ang2vec(const vec& r1, const vec& r2);
276 friend vec project_to_plane(const vec& r, const vec& normal);
277 // angle between projections of 2 vectors on plane normal to vector normal
278 // in interval [0, 2*M_PI]
279 // If one of vectors has zero length, it makes vecerror=1.
280 friend vfloat ang2projvec(const vec& r1, const vec& r2, const vec& normal);
281 // sinus of angle between vectors, 0 or positive.
282 // If one of vectors has zero length, it makes vecerror=1.
283 friend vfloat sin2vec(const vec& r1, const vec& r2);
284
285 /// Check whether two vectors are parallel, or anti-parallel.
286 /// Returns: 1 - parallel, -1 - antiparallel, 0 not parallel.
287 /// Also returns 0 if one or both vectors have zero length.
288 /// Thus, if angle between vectors < prec, they are parallel.
289 friend inline int check_par(const vec& r1, const vec& r2, vfloat prec);
290
291 /// Check whether two vectors are perpendicular.
292 /// Returns: 1 perpendicular, 0 not perpendicular.
293 /// Also returns 0 if one or both vectors have zero length.
294 /// Thus, if angle between vectors
295 /// a > 0.5 * M_PI - max(prec, vprecision) and
296 /// a < 0.5 * M_PI + max(prec, vprecision), they are perpendicular.
297 friend inline int check_perp(const vec& r1, const vec& r2, vfloat prec);
298 friend inline vec switch_xyz(const vec&); // don't change the vector itself
299
300};
301std::ostream& operator<<(std::ostream& file, const vec& v);
302
303extern vec dex; // unit vector by x
304extern vec dey; // unit vector by y
305extern vec dez; // unit vector by z
306extern vec dv0; // zero vector
307
308#include "wcpplib/geometry/vec.ic"
309
310/// Basis.
311class basis : public absref {
312 protected:
313 /// Unit vectors giving directions of Cartesian axes.
314 /// Supposed to be perpendicular, therefore not public.
316
317 virtual absref_transmit get_components() override;
318
319 static absref absref::*aref[3];
320
321 public:
322 std::string name;
323
324 public:
325 vec Gex() const { return ex; }
326 vec Gey() const { return ey; }
327 vec Gez() const { return ez; }
328
329 /// Change ex=ez; ey=ex; ez=ey.
330 basis switch_xyz() const;
331
332 /// Nominal basis.
333 basis();
334 /// Nominal basis.
335 basis(const std::string& pname);
336 /// Longitudinal basis.
337 /// z-axis is parallel to p.
338 /// y-axis is vector product of z_new and z_old
339 /// x-axis is vector product of y_new and z_new
340 /// If p is parallel to z_old, the copy of old basis is created.
341 /// If p is anti-parallel to z_old, the inverted copy of old basis is created.
342 basis(const vec& p, const std::string& fname);
343
344 /// More sophisticated basis.
345 /// ez is parallel to p, ez=unit_vec(p)
346 /// ey is perpendicular to plane which have p and c, ey=unit_vec(ez||c)
347 /// ex is vector product of y and z, ex=ey||ez
348 /// If p is parallel to c, or p is anti-parallel to c, vecerror=1
349 /// if(length(p)==0||length(c)==0)) vecerror=1;
350 basis(const vec& p, const vec& c, const std::string& pname);
351
352 /// Same basis with other name, useful for later turning.
353 basis(const basis& pb, const std::string& pname);
354 /// Direct definitions of basis by three perpendicular unit-length vectors.
355 basis(const vec& pex, const vec& pey, const vec& pez, const std::string& pname);
356
357 friend std::ostream& operator<<(std::ostream& file, const basis& b);
358 virtual basis* copy() const { return new basis(*this); }
359 virtual void print(std::ostream& file, int l) const;
360 virtual ~basis() {}
361};
362extern std::ostream& operator<<(std::ostream& file, const basis& b);
363
364/// Point.
365
366class point : public absref {
367 public:
369
370 private:
371 absref_transmit get_components() override;
372 static absref(absref::*aref);
373
374 public:
375 void down(const abssyscoor* fasc) override;
376 void up(const abssyscoor* fasc) override;
377 void shift(const vec& dir) override {
378 v += dir;
379 }
380 /// Default constructor (coordinates are not initialised).
381 point() : v() {}
382 /// Constructor from vector.
383 point(const vec& fv) : v(fv) {}
384 /// Constructor from coordinates.
385 point(const vfloat fex, const vfloat fey, const vfloat fez)
386 : v(fex, fey, fez) {}
387 point& operator=(const point& fp) {
388 v = fp.v;
389 return *this;
390 }
391 vec operator-(const point& pp) const { return v - pp.v; }
392 // creates vector from pp to p
393 point operator+(const vec& fv) const { return point(v + fv); }
394 friend int operator==(const point& p1, const point& p2) {
395 return p1.v == p2.v ? 1 : 0;
396 }
397 friend int operator!=(const point& p1, const point& p2) {
398 return p1.v != p2.v ? 1 : 0;
399 }
400 friend bool apeq(const point& p1, const point& p2, vfloat prec) {
401 return apeq(p1.v, p2.v, prec);
402 }
403 friend std::ostream& operator<<(std::ostream& file, const point& p);
404 virtual point* copy() const { return new point(*this); }
405 virtual void print(std::ostream& file, int l) const;
406 virtual ~point() {}
407};
408std::ostream& operator<<(std::ostream& file, const point& p);
409
410/// Coordinate system (centre, basis and mother coordinate system).
411/// Take care: c.abas must be equal to abas->ex.abas.
412/// If asc==NULL and abs(c)==0 than it is primary system of coordinate
413/// and therefore c.abas and abas->ex.abas must be zero,
414/// baz may be zero or pointer to unit basis.
415
416#define vec_syscoor_index 0
418 public:
419 std::string name = "none";
420 virtual const point* Gapiv() const = 0;
421 virtual const basis* Gabas() const = 0;
422 abssyscoor() = default;
423 abssyscoor(char* fname) : name(fname) {}
424 abssyscoor(const std::string& fname) : name(fname) {}
425 virtual void print(std::ostream& file, int l) const;
426
427 virtual ~abssyscoor() {}
428};
429extern std::ostream& operator<<(std::ostream& file, const abssyscoor& s);
430
431class fixsyscoor : public absref, public abssyscoor {
432 public:
433 const point* Gapiv() const override { return &piv; }
434 const basis* Gabas() const override { return &bas; }
435 void Ppiv(const point& fpiv);
436 void Pbas(const basis& fbas);
437 // nominal system
438 fixsyscoor() = default;
439 fixsyscoor(char* fname) : abssyscoor(fname) {}
440 fixsyscoor(const std::string& fname) : abssyscoor(fname) {}
441 fixsyscoor(const point& fpiv, const basis& fbas, const std::string& fname)
442 : abssyscoor(fname), piv(fpiv), bas(fbas) {}
443 fixsyscoor(const point* const fapiv, const basis* const fabas,
444 const std::string& fname)
445 : abssyscoor(fname),
446 piv((fapiv != NULL) ? (*fapiv) : point()),
447 bas((fabas != NULL) ? (*fabas) : basis()) {}
449 : abssyscoor(f),
450 piv((f.Gapiv() != NULL) ? (*(f.Gapiv())) : point()),
451 bas((f.Gabas() != NULL) ? (*(f.Gabas())) : basis()) {}
452 void print(std::ostream& file, int l) const override;
453 fixsyscoor* copy() const { return new fixsyscoor(*this); }
454 virtual ~fixsyscoor() {}
455
456 protected:
458 static absref(absref::*aref[2]);
459
460 private:
461 point piv;
462 basis bas;
463};
464extern std::ostream& operator<<(std::ostream& file, const fixsyscoor& s);
465}
466
467#endif
int qaref_other
Number of objects available though virtual function GetOther.
Definition: vec.h:147
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:138
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:127
absrefabsref::** aref
Definition: vec.h:130
absref_transmit(const absref_transmit &f)
Definition: vec.h:119
absref_transmit(int fqaref, absref absref::**faref)
Definition: vec.h:106
virtual absref_transmit * copy() const
Definition: vec.h:124
virtual ~absref_transmit()
Destructor.
Definition: vec.h:121
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:427
abssyscoor()=default
virtual const point * Gapiv() const =0
abssyscoor(const std::string &fname)
Definition: vec.h:424
virtual const basis * Gabas() const =0
std::string name
Definition: vec.h:419
abssyscoor(char *fname)
Definition: vec.h:423
Basis.
Definition: vec.h:311
virtual basis * copy() const
Definition: vec.h:358
virtual absref_transmit get_components() override
Definition: vec.cpp:272
vec ez
Definition: vec.h:315
virtual ~basis()
Definition: vec.h:360
basis()
Nominal basis.
Definition: vec.cpp:281
std::string name
Definition: vec.h:322
vec Gez() const
Definition: vec.h:327
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:315
vec Gey() const
Definition: vec.h:326
static absref absref::* aref[3]
Definition: vec.h:319
vec ey
Definition: vec.h:315
vec Gex() const
Definition: vec.h:325
virtual void print(std::ostream &file, int l) const
Definition: vec.cpp:387
fixsyscoor(char *fname)
Definition: vec.h:439
const basis * Gabas() const override
Definition: vec.h:434
fixsyscoor()=default
void Ppiv(const point &fpiv)
Definition: vec.cpp:477
fixsyscoor * copy() const
Definition: vec.h:453
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:441
fixsyscoor(const point *const fapiv, const basis *const fabas, const std::string &fname)
Definition: vec.h:443
virtual ~fixsyscoor()
Definition: vec.h:454
fixsyscoor(const abssyscoor &f)
Definition: vec.h:448
fixsyscoor(const std::string &fname)
Definition: vec.h:440
const point * Gapiv() const override
Definition: vec.h:433
static absrefabsref::*[2] aref
Definition: vec.h:458
Point.
Definition: vec.h:366
virtual ~point()
Definition: vec.h:406
void shift(const vec &dir) override
Definition: vec.h:377
point()
Default constructor (coordinates are not initialised).
Definition: vec.h:381
point operator+(const vec &fv) const
Definition: vec.h:393
friend int operator!=(const point &p1, const point &p2)
Definition: vec.h:397
friend bool apeq(const point &p1, const point &p2, vfloat prec)
Definition: vec.h:400
point & operator=(const point &fp)
Definition: vec.h:387
point(const vfloat fex, const vfloat fey, const vfloat fez)
Constructor from coordinates.
Definition: vec.h:385
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:391
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:394
vec v
Definition: vec.h:368
point(const vec &fv)
Constructor from vector.
Definition: vec.h:383
virtual point * copy() const
Definition: vec.h:404
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:177
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:223
friend int check_perp(const vec &r1, const vec &r2, vfloat prec)
friend vec operator+(const vec &r1, const vec &r2)
Definition: vec.h:238
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:245
vfloat x
Definition: vec.h:190
friend vfloat operator*(const vec &r1, const vec &r2)
Definition: vec.h:253
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:234
friend vec operator||(const vec &r1, const vec &r2)
Vector product.
Definition: vec.h:257
vfloat length() const
Definition: vec.h:194
vfloat z
Definition: vec.h:192
friend vec operator-=(vec &r1, const vec &r2)
Definition: vec.h:248
vec operator/(vfloat p) const
Definition: vec.h:233
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:241
friend vec switch_xyz(const vec &)
friend vec operator-(const vec &r)
Definition: vec.h:252
friend vec operator*=(vec &v, vfloat p)
Definition: vec.h:226
friend int check_par(const vec &r1, const vec &r2, vfloat prec)
friend vec operator*(vfloat p, const vec &v)
Definition: vec.h:230
virtual ~vec()
Destructor.
Definition: vec.h:188
vec(vfloat xx, vfloat yy, vfloat zz)
Constructor.
Definition: vec.h:180
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:195
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:191
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:306
int vecerror
Definition: vec.cpp:29
vec dex(1, 0, 0)
Definition: vec.h:303
vec dez(0, 0, 1)
Definition: vec.h:305
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
vec dey(0, 1, 0)
Definition: vec.h:304
double vfloat
Definition: vfloat.h:16