4#define _USE_MATH_DEFINES
33 Ifile <<
"absref_transmit::print(l=" << l <<
") qaref=" <<
qaref
44 if (fasc == NULL)
return;
49 if (fasc == NULL)
return;
69 pvecerror(
"vfloat cos2vec(const vec& r1, const vec& r2)");
75 if (lr1 == 0 || lr2 == 0) {
81 if (cs < 0) sign = -1;
83 cs = sign *
sqrt(cs / (lr1 * lr2));
95 if (cs > 0.707106781187 || cs < -0.707106781187) {
102 return M_PI -
asin(sn);
109 pvecerror(
"vfloat sin2vec(const vec& r1, const vec& r2)");
112 if (lr1 == 0 || lr2 == 0) {
116 vfloat sn = (r1 || r2).length();
118 sn =
sqrt(sn / (lr1 * lr2));
125 pvecerror(
"vec project_to_plane(const vec& r, const vec& normal)");
126 vec per(normal || r);
131 vec ax = unit_vec(per || normal);
138 "vfloat ang2projvec(const vec& r1, const vec& r2, const vec& normal)");
141 if (rt1 ==
dv0 || rt2 ==
dv0) {
146 if (tang == 0)
return tang;
148 int i = check_par(at, normal, 0.0001);
152 if (i == -1)
return 2.0 * M_PI - tang;
162 r.
x =
x * ex.
x +
y * ey.
x +
z * ez.
x;
163 r.
y =
x * ex.
y +
y * ey.
y +
z * ez.
y;
164 r.
z =
x * ex.
z +
y * ey.
z +
z * ez.
z;
172 pvecerrorp(
"vec vec::up_new((const basis *pbas)");
176 if (fabas_new == NULL) {
178 mcerr <<
"fabas_new==NULL\n";
181 vec ex = fabas_new->
Gex();
182 vec ey = fabas_new->
Gey();
183 vec ez = fabas_new->
Gez();
184 r.
x =
x * ex.
x +
y * ex.
y +
z * ex.
z;
185 r.
y =
x * ey.
x +
y * ey.
y +
z * ey.
z;
186 r.
z =
x * ez.
x +
y * ez.
y +
z * ez.
z;
193 pvecerror(
"vec turn(vec& dir, vfloat& angle)");
194 if ((*this).length() == 0)
return vec(0, 0, 0);
201 vec u = dir / dirlen;
202 vec constcomp = u * (*this) * u;
204 vec ort2 = ort1 || u;
205 vec perpcomp = ort2 * (*this) * ort2;
208 ort1 =
sin(angle) * len * ort1;
209 ort2 =
cos(angle) * len * ort2;
213 return constcomp + ort1 + ort2;
230 const vfloat phi = M_PI * 2.0 * SRANLUX();
237 vfloat phi = M_PI * 2.0 * SRANLUX();
238 double stheta =
sin(theta);
239 x =
sin(phi) * stheta;
240 y =
cos(phi) * stheta;
245 vfloat cteta = 2.0 * SRANLUX() - 1.0;
248 *
this = (*this) * steta;
253 Ifile <<
"vector=" << std::setw(13) << v.
x << std::setw(13) << v.
y
254 << std::setw(13) << v.
z;
268 reinterpret_cast<absref absref::*
>(
static_cast<vec absref::*
>(&
basis::ex)),
269 reinterpret_cast<absref absref::*
>(
static_cast<vec absref::*
>(&
basis::ey)),
270 reinterpret_cast<absref absref::*
>(
static_cast<vec absref::*
>(&
basis::ez))};
277 pvecerror(
"basis basis::switch_xyz(void)");
282 name =
"primary_bas";
285basis::basis(
const std::string& pname) : ex(1, 0, 0), ey(0, 1, 0), ez(0, 0, 1) {
306 }
else if (ca == -1) {
318 pvecerror(
"basis::basis(vec &p, vec &c, char pname[12])");
333 }
else if (ca == -1) {
340 ey = unit_vec(
ez || c);
347 : ex(pb.ex), ey(pb.ey), ez(pb.ez) {
352 const std::string& pname) {
353 pvecerror(
"basis::basis(vec &pex, vec &pey, vec &pez, char pname[12])");
356 mcerr <<
"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n"
357 <<
"the vectors are not perpendicular\n";
358 mcerr <<
" pex,pey,pez:\n";
359 mcerr << pex << pey << pez;
360 mcerr <<
"name=" << pname <<
'\n';
366 mcerr <<
"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n"
367 <<
"the vectors are not of unit length\n";
368 mcerr <<
" pex,pey,pez:\n";
369 mcerr << pex << pey << pez;
370 mcerr <<
"name=" << pname <<
'\n';
374 mcerr <<
"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n";
375 mcerr <<
"wrong direction of pez\n";
376 mcerr <<
" pex,pey,pez:\n";
377 mcerr << pex << pey << pez;
378 mcerr <<
"name=" << pname <<
'\n';
390 Ifile <<
"basis: name=" << b.
name <<
'\n';
392 int indnsave =
indn.
n;
441 Ifile <<
"abssyscoor::print(l=" << l <<
"): name=" <<
name <<
'\n';
448 Ifile <<
"apiv=NULL\n";
454 Ifile <<
"abas=NULL\n";
468 reinterpret_cast<absref absref::*
>(
469 static_cast<point absref::*
>(&fixsyscoor::piv)),
470 reinterpret_cast<absref absref::*
>(
471 static_cast<basis absref::*
>(&fixsyscoor::bas))};
482 Ifile <<
"fixsyscoor::print(l=" << l <<
")\n";
491 Ifile <<
"fixsyscoor:\n";
492 f.abssyscoor::print(file, 2);
#define check_econd11a(a, signb, add, stream)
int qaref_other
Number of objects available though virtual function GetOther.
virtual void print(std::ostream &file, int l) const
virtual absref * get_other(int n)
int qaref
Number of vector objects which are the members of the class.
virtual void up(const abssyscoor *fasc)
Convert numbering representation of objects to new system.
virtual void shift(const vec &dir)
virtual void down(const abssyscoor *fasc)
Convert numbering representation of object to basical system of fasc.
virtual void turn(const vec &dir, vfloat angle)
Turn around axis doing via center of coordinate system along dir.
virtual void print(std::ostream &file, int l) const
virtual const point * Gapiv() const =0
virtual const basis * Gabas() const =0
virtual absref_transmit get_components() override
basis switch_xyz() const
Change ex=ez; ey=ex; ez=ey.
static absref absref::* aref[3]
virtual void print(std::ostream &file, int l) const
void Ppiv(const point &fpiv)
static absref absref::* aref[2]
absref_transmit get_components() override
void Pbas(const basis &fbas)
void print(std::ostream &file, int l) const override
void shift(const vec &dir) override
void up(const abssyscoor *fasc) override
Convert numbering representation of objects to new system.
void down(const abssyscoor *fasc) override
Convert numbering representation of object to basical system of fasc.
virtual void print(std::ostream &file, int l) const
void turn(const vec &dir, vfloat angle) override
Turn this vector.
vec up_new(const basis *fabas_new)
void shift(const vec &dir) override
vec turn_new(const vec &dir, vfloat angle)
Make new turned vector and leave this one unchanged.
void up(const basis *fabas_new)
void random_conic_vec(double theta)
friend int check_par(const vec &r1, const vec &r2, vfloat prec)
friend vec unit_vec(const vec &v)
vec()=default
Default constructor.
void down(const basis *fabas)
void random_round_vec()
Generate random unit vector in plane perpendicular to z-axis.
vec down_new(const basis *fabas)
DoubleAc cos(const DoubleAc &f)
vfloat ang2projvec(const vec &r1, const vec &r2, const vec &normal)
std::ostream & noindent(std::ostream &f)
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
vec project_to_plane(const vec &r, const vec &normal)
bool apeq(const circumf &f1, const circumf &f2, vfloat prec)
vfloat sin2vec(const vec &r1, const vec &r2)
DoubleAc acos(const DoubleAc &f)
vfloat cos2vec(const vec &r1, const vec &r2)
vfloat ang2vec(const vec &r1, const vec &r2)
DoubleAc sin(const DoubleAc &f)
DoubleAc asin(const DoubleAc &f)
DoubleAc sqrt(const DoubleAc &f)
#define pvecerrorp(string)
#define ApplyAnyFunctionToVecElements(func)
#define pvecerror(string)