Garfield++ v2r0
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>
28
29#define pvecerror(string) \
30 mfunname(string); \
31 if (vecerror != 0) { \
32 mcerr << "vecerror is not zero, program is terminated\n" \
33 << " function detected error is " << string << '\n'; \
34 spexit(mcerr); \
35 }
36#define pvecerrorp(string) \
37 mfunnamep(string); \
38 if (vecerror != 0) { \
39 mcerr << "vecerror is not zero, program is terminated\n" \
40 << " function detected error is " << string << '\n'; \
41 spexit(mcerr); \
42 }
43// pvecerror is put after first line of function.
44// It makes up stack of functions names if FUNNAMESTACK is defined.
45// To work correctly stackline(string); should not be in any additional {}
46
48/* Introduces type vfloat which is used throughout the geometrical calculations
49instead of double. 'double' is meant to be replacable by 'float' for
50speeding up, but no consistent research was made to check that it really
51works in this way. So now vfloat is synonym of double.
52*/
53
54namespace Heed {
55
56extern int vecerror;
57
58class vec;
59class basis; // It is ortogonal basis
60class abssyscoor;
61class point;
62
63class absref_transmit;
64
65/// Abstract reference, base class for any geometrical vector object.
66/// Used for arranging of shift, turn and shange of coordinate system of
67/// vector objects. Four functions down(), up(), turn(), and shift() do that
68/// by calling of the same functions for any vector objects which are parts
69/// of this class.
70/// Address of parts lets known by virtual function get_components()
71/// which is reloaded in any derivative class.
72/// Class vec represents three-vectors and
73/// reloads the functions down(), up(), turn() with proper functions
74/// manipulating with three-vectors.
75/// Function shift() is also reloaded and does nothing for 3-vector vec,
76/// since it is assumed that 3-vector is characteristic of direction only,
77/// not point in space. We can not shift direction.
78/// For this reason, class point representing point in space
79/// reloads functions down and up again, and, of course, reloads shift.
80/// To make proper shift at switch to coordinate system with shifted center
81/// the point::down() and point::up() functions apply point::shift() function
82/// after or before vec::down() and vec::up().
83
84class absref {
85 public:
86 /// Destructor
87 virtual ~absref() {}
88 /// Convert numbering representation of object to basical system of fasc
89 virtual void down(const abssyscoor* fasc);
90 /// Convert numbering representation of objects to new system
91 virtual void up(const abssyscoor* fasc);
92 /// Turn around axis doing via center of coordinate system along dir.
93 virtual void turn(const vec& dir, vfloat angle);
94 virtual void shift(const vec& dir);
95
96 private:
97 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
98};
99
100// Contains three methods of transmission, the fastest, slower and the slowest
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), qaref_pointer(0), qaref_other(0) {}
108 absref_transmit(int fqaref_pointer, absref** faref_pointer)
109 : qaref(0),
110 qaref_pointer(fqaref_pointer),
111 aref_pointer(faref_pointer),
112 qaref_other(0) {}
113 absref_transmit(int fqaref, absref absref::** faref, int fqaref_pointer,
114 absref** faref_pointer)
115 : qaref(fqaref),
116 aref(faref),
117 qaref_pointer(fqaref_pointer),
118 aref_pointer(faref_pointer),
119 qaref_other(0) {}
120
121 absref_transmit(const absref_transmit& f) { *this = f; }
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;
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.
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 ActivePtr<absref_transmit> aref_tran_cont; \
160 get_components(aref_tran_cont); \
161 absref_transmit* aref_tran = aref_tran_cont.get(); \
162 if (aref_tran != NULL) { \
163 int n; \
164 int q = aref_tran->qaref; \
165 for (n = 0; n < q; n++) (this->*(aref_tran->aref[n])).func; \
166 q = aref_tran->qaref_pointer; \
167 for (n = 0; n < q; n++) aref_tran->aref_pointer[n]->func; \
168 q = aref_tran->qaref_other; \
169 for (n = 0; n < q; n++) { \
170 absref* ar = aref_tran->get_other(n); \
171 if (ar == NULL) \
172 break; \
173 else \
174 ar->func; \
175 } \
176 } \
177 }
178
179/// Vector.
180/// Each vector is presented by three components and corresponds to some basis.
181/// // The components are a projection of the vector to unit basis vectors.
182/// If bas==NULL then it is the primary basis.
183/// So the concept of vector is more primary concept with comparison of
184/// basis, since one can not postulate basis while vectors do not exist.
185
186class vec : public absref {
187 public:
188 /// Constructor.
189 vec(vfloat xx, vfloat yy, vfloat zz) {
190 x = xx;
191 y = yy;
192 z = zz;
193 }
194 /// Default constructor.
195 vec() {
196 x = 0;
197 y = 0;
198 z = 0;
199 }
200 /// Destructor
201 virtual ~vec() {}
202
204
205 vfloat length() const { return sqrt(x * x + y * y + z * z); }
206 vfloat length2() const { return x * x + y * y + z * z; }
207
208 vec down_new(const basis* fabas);
209 void down(const basis* fabas);
210 vec up_new(const basis* fabas_new);
211 void up(const basis* fabas_new);
212 vec down_new(const abssyscoor* fasc);
213 void down(const abssyscoor* fasc);
214 vec up_new(const abssyscoor* fasc);
215 void up(const abssyscoor* fasc);
216
217 // make new turned vector and leave this unchanged
218 vec turn_new(const vec& dir, vfloat angle);
219 /// Turn this vector
220 void turn(const vec& dir, vfloat angle);
221 void shift(const vec& dir);
222
223 /// Generate random unit vector in plane perpendicular to z-axis.
224 void random_round_vec();
225 /// Generate random unit vector in any direction in conus
226 /// with symmetry axis along z-axis and with angle theta (radian).
227 void random_conic_vec(double theta);
228 // Generate random unit vector in any direction in 3D space.
229 void random_sfer_vec();
230
231 friend vec operator*(const vec& v, vfloat p) {
232 return vec(v.x * p, v.y * p, v.z * p);
233 }
234 friend vec operator*=(vec& v, vfloat p) {
235 v = v * p;
236 return v;
237 }
238 friend vec operator*(vfloat p, const vec& v) {
239 return vec(v.x * p, v.y * p, v.z * p);
240 }
241 vec operator/(vfloat p) const { return vec(x / p, y / p, z / p); }
242 friend vec operator/=(vec& v, vfloat p) {
243 v = v / p;
244 return v;
245 }
246 friend vec operator+(const vec& r1, const vec& r2) {
247 return vec(r1.x + r2.x, r1.y + r2.y, r1.z + r2.z);
248 }
249 friend vec& operator+=(vec& r1, const vec& r2) {
250 r1 = r1 + r2;
251 return r1;
252 }
253 friend vec operator-(const vec& r1, const vec& r2) {
254 return vec(r1.x - r2.x, r1.y - r2.y, r1.z - r2.z);
255 }
256 friend vec operator-=(vec& r1, const vec& r2) {
257 r1 = r1 - r2;
258 return r1;
259 }
260 friend vec operator-(const vec& r) { return vec(-r.x, -r.y, -r.z); }
261 friend vfloat operator*(const vec& r1, const vec& r2) {
262 return r1.x * r2.x + r1.y * r2.y + r1.z * r2.z;
263 }
264 /// Vector product.
265 friend vec operator||(const vec& r1, const vec& r2) {
266 return vec(r1.y * r2.z - r1.z * r2.y, r1.z * r2.x - r1.x * r2.z,
267 r1.x * r2.y - r1.y * r2.x);
268 }
269 /// Return 1 if precisely the same vectors and 0 otherwise.
270 friend inline int operator==(const vec& r1, const vec& r2);
271 /// Return 0 if precisely the same vectors and 1 otherwise.
272 friend inline int operator!=(const vec& r1, const vec& r2);
273
274 /// Return true if two vectors are approximately the same.
275 friend inline bool apeq(const vec& r1, const vec& r2, vfloat prec);
276
277 friend inline vec unit_vec(const vec& v);
278 // cosinus of angle between vectors
279 // If one of vectors has zero length, it makes vecerror=1 and returns 0.
280 friend vfloat cos2vec(const vec& r1, const vec& r2);
281 // angle between vectors, in interval [0, M_PI]
282 // If one of vectors has zero length, it makes vecerror=1.
283 friend vfloat ang2vec(const vec& r1, const vec& r2);
284 friend vec project_to_plane(const vec& r, const vec& normal);
285 // angle between projections of 2 vectors on plane normal to vector normal
286 // in interval [0, 2*M_PI]
287 // If one of vectors has zero length, it makes vecerror=1.
288 friend vfloat ang2projvec(const vec& r1, const vec& r2, const vec& normal);
289 // sinus of angle between vectors, 0 or positive.
290 // If one of vectors has zero length, it makes vecerror=1.
291 friend vfloat sin2vec(const vec& r1, const vec& r2);
292
293 /// Check whether two vectors are parallel, or anti-parallel.
294 /// Returns: 1 - parallel, -1 - antiparallel, 0 not parallel.
295 /// Also returns 0 if one or both vectors have zero length.
296 /// Thus, if angle between vectors < prec, they are parallel.
297 friend inline int check_par(const vec& r1, const vec& r2, vfloat prec);
298
299 /// Check whether two vectors are perpendicular.
300 /// Returns: 1 perpendicular, 0 not perpendicular.
301 /// Also returns 0 if one or both vectors have zero length.
302 /// Thus, if angle between vectors
303 /// a > 0.5 * M_PI - max(prec, vprecision) and
304 /// a < 0.5 * M_PI + max(prec, vprecision), they are perpendicular.
305 friend inline int check_perp(const vec& r1, const vec& r2, vfloat prec);
306 friend inline vec switch_xyz(const vec&); // don't change the vector itself
307
308};
309std::ostream& operator<<(std::ostream& file, const vec& v);
310
311extern vec dex; // unit vector by x
312extern vec dey; // unit vector by y
313extern vec dez; // unit vector by z
314extern vec dv0; // zero vector
315
316#include "wcpplib/geometry/vec.ic"
317
318/// Basis.
319class basis : public absref {
320 protected:
321 /// Unit vectors giving directions of Cartesian axes.
322 /// Supposed to be perpendicular, therefore not public.
324
325 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
326
327 static absref absref::*aref[3];
328
329 public:
330 std::string name;
331
332 public:
333 vec Gex() const { return ex; }
334 vec Gey() const { return ey; }
335 vec Gez() const { return ez; }
336
337 /// Change ex=ez; ey=ex; ez=ey.
338 basis switch_xyz() const;
339
340 /// Nominal basis.
341 basis();
342 /// Nominal basis.
343 basis(const std::string& pname);
344 /// Longitudinal basis.
345 /// z-axis is parallel to p.
346 /// y-axis is vector product of z_new and z_old
347 /// x-axis is vector product of y_new and z_new
348 /// If p is parallel to z_old, the copy of old basis is created.
349 /// If p is anti-parallel to z_old, the inverted copy of old basis is created.
350 basis(const vec& p, const std::string& fname);
351
352 /// More sophisticated basis.
353 /// ez is parallel to p, ez=unit_vec(p)
354 /// ey is perpendicular to plane which have p and c, ey=unit_vec(ez||c)
355 /// ex is vector product of y and z, ex=ey||ez
356 /// If p is parallel to c, or p is anti-parallel to c, vecerror=1
357 /// if(length(p)==0||length(c)==0)) vecerror=1;
358 basis(const vec& p, const vec& c, const std::string& pname);
359
360 /// Same basis with other name, useful for later turning.
361 basis(const basis& pb, const std::string& pname);
362 /// Direct definitions of basis by three perpendicular unit-length vectors.
363 basis(const vec& pex, const vec& pey, const vec& pez, const std::string& pname);
364
365 friend std::ostream& operator<<(std::ostream& file, const basis& b);
366 virtual basis* copy() const { return new basis(*this); }
367 virtual void print(std::ostream& file, int l) const;
368 virtual ~basis() {}
369};
370extern std::ostream& operator<<(std::ostream& file, const basis& b);
371
372/// Point.
373
374class point : public absref {
375 public:
377
378 private:
379 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
380 static absref(absref::*aref);
381
382 public:
383 virtual void down(const abssyscoor* fasc);
384 virtual void up(const abssyscoor* fasc);
385 virtual void shift(const vec& dir) {
386 // not defined for vectors, but defined for points
387 v += dir;
388 }
389 /// Default constructor (coordinates are not initialised).
390 point() : v() {}
391 /// Constructor from vector.
392 point(const vec& fv) : v(fv) {}
393 /// Constructor from coordinates.
394 point(const vfloat fex, const vfloat fey, const vfloat fez)
395 : v(fex, fey, fez) {}
396 point& operator=(const point& fp) {
397 v = fp.v;
398 return *this;
399 }
400 vec operator-(const point& pp) const { return v - pp.v; }
401 // creates vector from pp to p
402 point operator+(const vec& fv) const { return point(v + fv); }
403 friend int operator==(const point& p1, const point& p2) {
404 return p1.v == p2.v ? 1 : 0;
405 }
406 friend int operator!=(const point& p1, const point& p2) {
407 return p1.v != p2.v ? 1 : 0;
408 }
409 friend bool apeq(const point& p1, const point& p2, vfloat prec) {
410 return apeq(p1.v, p2.v, prec);
411 }
412 friend std::ostream& operator<<(std::ostream& file, const point& p);
413 virtual point* copy() const { return new point(*this); }
414 virtual void print(std::ostream& file, int l) const;
415 virtual ~point() {}
416};
417std::ostream& operator<<(std::ostream& file, const point& p);
418
419/// Coordinate system (centre, basis and mother coordinate system).
420/// Take care: c.abas must be equal to abas->ex.abas.
421/// If asc==NULL and abs(c)==0 than it is primary system of coordinate
422/// and therefore c.abas and abas->ex.abas must be zero,
423/// baz may be zero or pointer to unit basis.
424
425#define vec_syscoor_index 0
427 public:
428 std::string name;
429 virtual const point* Gapiv() const = 0;
430 virtual const basis* Gabas() const = 0;
431 abssyscoor() : name("none") {}
432 abssyscoor(char* fname) : name(fname) {}
433 abssyscoor(const std::string& fname) : name(fname) {}
434 virtual void print(std::ostream& file, int l) const;
435
436 virtual ~abssyscoor() {}
437};
438extern std::ostream& operator<<(std::ostream& file, const abssyscoor& s);
439
440class fixsyscoor : public absref, public abssyscoor, public RegPassivePtr {
441 public:
442 virtual const point* Gapiv() const { return &piv; }
443 virtual const basis* Gabas() const { return &bas; }
444 void Ppiv(const point& fpiv);
445 void Pbas(const basis& fbas);
446 // nominal system
448 fixsyscoor(char* fname) : abssyscoor(fname) {}
449 fixsyscoor(const std::string& fname) : abssyscoor(fname) {}
450 fixsyscoor(const point& fpiv, const basis& fbas, const std::string& fname)
451 : abssyscoor(fname), piv(fpiv), bas(fbas) {}
452 fixsyscoor(const point* const fapiv, const basis* const fabas,
453 const std::string& fname)
454 : abssyscoor(fname),
455 piv((fapiv != NULL) ? (*fapiv) : point()),
456 bas((fabas != NULL) ? (*fabas) : basis()) {}
458 : abssyscoor(f),
459 piv((f.Gapiv() != NULL) ? (*(f.Gapiv())) : point()),
460 bas((f.Gabas() != NULL) ? (*(f.Gabas())) : basis()) {}
461 virtual void print(std::ostream& file, int l) const;
462 virtual fixsyscoor* copy() const { return new fixsyscoor(*this); }
463 virtual ~fixsyscoor() {}
464
465 protected:
466 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
467 static absref(absref::*aref[2]);
468
469 private:
470 point piv;
471 basis bas;
472};
473extern std::ostream& operator<<(std::ostream& file, const fixsyscoor& s);
474}
475
476#endif
Active pointer or automatic container or controlling pointer.
Definition: AbsPtr.h:199
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:113
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
absrefabsref::** aref
Definition: vec.h:132
absref_transmit(const absref_transmit &f)
Definition: vec.h:121
absref_transmit(int fqaref, absref absref::**faref)
Definition: vec.h:106
virtual absref_transmit * copy() const
Definition: vec.h:126
virtual ~absref_transmit()
Destructor.
Definition: vec.h:123
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:87
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:436
virtual const point * Gapiv() const =0
abssyscoor(const std::string &fname)
Definition: vec.h:433
virtual const basis * Gabas() const =0
std::string name
Definition: vec.h:428
abssyscoor(char *fname)
Definition: vec.h:432
Basis.
Definition: vec.h:319
virtual basis * copy() const
Definition: vec.h:366
vec ez
Definition: vec.h:323
virtual ~basis()
Definition: vec.h:368
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
Definition: vec.cpp:272
basis()
Nominal basis.
Definition: vec.cpp:281
std::string name
Definition: vec.h:330
vec Gez() const
Definition: vec.h:335
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:323
vec Gey() const
Definition: vec.h:334
static absref absref::* aref[3]
Definition: vec.h:327
vec ey
Definition: vec.h:323
vec Gex() const
Definition: vec.h:333
virtual void print(std::ostream &file, int l) const
Definition: vec.cpp:387
fixsyscoor(char *fname)
Definition: vec.h:448
virtual fixsyscoor * copy() const
Definition: vec.h:462
void Ppiv(const point &fpiv)
Definition: vec.cpp:477
virtual void print(std::ostream &file, int l) const
Definition: vec.cpp:480
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
Definition: vec.cpp:473
virtual const basis * Gabas() const
Definition: vec.h:443
void Pbas(const basis &fbas)
Definition: vec.cpp:478
fixsyscoor(const point &fpiv, const basis &fbas, const std::string &fname)
Definition: vec.h:450
fixsyscoor(const point *const fapiv, const basis *const fabas, const std::string &fname)
Definition: vec.h:452
virtual ~fixsyscoor()
Definition: vec.h:463
fixsyscoor(const abssyscoor &f)
Definition: vec.h:457
fixsyscoor(const std::string &fname)
Definition: vec.h:449
static absrefabsref::*[2] aref
Definition: vec.h:467
virtual const point * Gapiv() const
Definition: vec.h:442
Point.
Definition: vec.h:374
virtual void down(const abssyscoor *fasc)
Convert numbering representation of object to basical system of fasc.
Definition: vec.cpp:418
virtual ~point()
Definition: vec.h:415
point()
Default constructor (coordinates are not initialised).
Definition: vec.h:390
point operator+(const vec &fv) const
Definition: vec.h:402
friend int operator!=(const point &p1, const point &p2)
Definition: vec.h:406
virtual void up(const abssyscoor *fasc)
Convert numbering representation of objects to new system.
Definition: vec.cpp:422
friend bool apeq(const point &p1, const point &p2, vfloat prec)
Definition: vec.h:409
point & operator=(const point &fp)
Definition: vec.h:396
point(const vfloat fex, const vfloat fey, const vfloat fez)
Constructor from coordinates.
Definition: vec.h:394
vec operator-(const point &pp) const
Definition: vec.h:400
friend int operator==(const point &p1, const point &p2)
Definition: vec.h:403
vec v
Definition: vec.h:376
point(const vec &fv)
Constructor from vector.
Definition: vec.h:392
virtual point * copy() const
Definition: vec.h:413
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
virtual void shift(const vec &dir)
Definition: vec.h:385
Definition: vec.h:186
vec()
Default constructor.
Definition: vec.h:195
vec up_new(const basis *fabas_new)
Definition: vec.cpp:170
friend vec operator*(const vec &v, vfloat p)
Definition: vec.h:231
friend int check_perp(const vec &r1, const vec &r2, vfloat prec)
friend vec operator+(const vec &r1, const vec &r2)
Definition: vec.h:246
friend vfloat ang2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:89
vec turn_new(const vec &dir, vfloat angle)
Definition: vec.cpp:192
friend vec operator-(const vec &r1, const vec &r2)
Definition: vec.h:253
vfloat x
Definition: vec.h:203
friend vfloat operator*(const vec &r1, const vec &r2)
Definition: vec.h:261
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:242
friend vec operator||(const vec &r1, const vec &r2)
Vector product.
Definition: vec.h:265
vfloat length() const
Definition: vec.h:205
vfloat z
Definition: vec.h:203
friend vec operator-=(vec &r1, const vec &r2)
Definition: vec.h:256
vec operator/(vfloat p) const
Definition: vec.h:241
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:249
friend vec switch_xyz(const vec &)
friend vec operator-(const vec &r)
Definition: vec.h:260
friend vec operator*=(vec &v, vfloat p)
Definition: vec.h:234
friend int check_par(const vec &r1, const vec &r2, vfloat prec)
friend vec operator*(vfloat p, const vec &v)
Definition: vec.h:238
virtual ~vec()
Destructor.
Definition: vec.h:201
vec(vfloat xx, vfloat yy, vfloat zz)
Constructor.
Definition: vec.h:189
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
vfloat length2() const
Definition: vec.h:206
void turn(const vec &dir, vfloat angle)
Turn this vector.
Definition: vec.cpp:216
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 shift(const vec &dir)
Definition: vec.cpp:220
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:203
Definition: BGMesh.cpp:5
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:36
vec dv0(0, 0, 0)
Definition: vec.h:314
int vecerror
Definition: vec.cpp:29
vec dex(1, 0, 0)
Definition: vec.h:311
vec dez(0, 0, 1)
Definition: vec.h:313
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
vec dey(0, 1, 0)
Definition: vec.h:312
double vfloat
Definition: vfloat.h:16