4#define _USE_MATH_DEFINES
17#include <CLHEP/Random/RandomEngine.h>
37void absref_transmit::print(std::ostream& file,
int l)
const {
39 Ifile <<
"absref_transmit::print(l=" << l <<
") qaref=" << qaref
40 <<
" qaref_pointer=" << qaref_pointer
41 <<
" qaref_other=" << qaref_other <<
"\n";
46absref* absref_transmit::get_other(
int ) {
return NULL; }
51 if (fasc == NULL)
return;
56 if (fasc == NULL)
return;
68void absref::get_components(ActivePtr<absref_transmit>& aref_tran) {
145 pvecerror(
"vfloat cos2vec(const vec& r1, const vec& r2)");
151 if (lr1 == 0 || lr2 == 0) {
157 if (cs < 0) sign = -1;
159 cs = sign *
sqrt(cs / (lr1 * lr2));
171 if (cs > 0.707106781187 || cs < -0.707106781187) {
178 return M_PI -
asin(sn);
185 pvecerror(
"vfloat sin2vec(const vec& r1, const vec& r2)");
188 if (lr1 == 0 || lr2 == 0) {
192 vfloat sn = length(r1 || r2);
194 sn =
sqrt(sn / (lr1 * lr2));
201 pvecerror(
"vec project_to_plane(const vec& r, const vec& normal)");
202 vec per(normal || r);
207 vec ax = unit_vec(per || normal);
214 "vfloat ang2projvec(const vec& r1, const vec& r2, const vec& normal)");
217 if (rt1 ==
dv0 || rt2 ==
dv0) {
222 if (tang == 0)
return tang;
224 int i = check_par(at, normal, 0.0001);
228 if (i == -1)
return 2.0 * M_PI - tang;
238 r.
x =
x * ex.
x +
y * ey.
x +
z * ez.
x;
239 r.
y =
x * ex.
y +
y * ey.
y +
z * ez.
y;
240 r.
z =
x * ex.
z +
y * ey.
z +
z * ez.
z;
251 pvecerrorp(
"vec vec::up_new((const basis *pbas)");
255 if (fabas_new == NULL) {
257 mcerr <<
"fabas_new==NULL\n";
260 vec ex = fabas_new->
Gex();
261 vec ey = fabas_new->
Gey();
262 vec ez = fabas_new->
Gez();
263 r.
x =
x * ex.
x +
y * ex.
y +
z * ex.
z;
264 r.
y =
x * ey.
x +
y * ey.
y +
z * ey.
z;
265 r.
z =
x * ez.
x +
y * ez.
y +
z * ez.
z;
272 pvecerror(
"vec turn(vec& dir, vfloat& angle)");
273 if (
length(*
this) == 0)
return vec(0, 0, 0);
280 vec u = dir / dirlen;
281 vec constcomp = u * (*this) * u;
285 vec ort2 = ort1 || u;
286 vec perpcomp = ort2 * (*this) * ort2;
289 ort1 =
sin(angle) * len * ort1;
290 ort2 =
cos(angle) * len * ort2;
294 return constcomp + ort1 + ort2;
328 double stheta =
sin(theta);
329 x =
sin(phi) * stheta;
330 y =
cos(phi) * stheta;
342 *
this = (*this) * steta;
347 Ifile <<
"vector=" << std::setw(13) << v.
x << std::setw(13) << v.
y
348 << std::setw(13) << v.
z;
364#ifndef WCPPLIB_INLINE
365#include "geometry/vec.ic"
380 aref_tran.pass(
new absref_transmit(3,
aref));
389 pvecerror(
"basis basis::switch_xyz(void)");
394 name =
"primary_bas";
408 if (length(p) == 0) {
419 }
else if (ca == -1) {
431 pvecerror(
"basis::basis(vec &p, vec &c, char pname[12])");
437 if (length(p) == 0 || length(c) == 0) {
449 }
else if (ca == -1) {
456 ey = unit_vec(
ez || c);
464 : ex(pb.ex), ey(pb.ey), ez(pb.ez) {
470 pvecerror(
"basis::basis(vec &pex, vec &pey, vec &pez, char pname[12])");
473 mcerr <<
"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n"
474 <<
"the vectors are not perpendicular\n";
475 mcerr <<
" pex,pey,pez:\n";
476 mcerr << pex << pey << pez;
477 mcerr <<
"name=" << pname <<
'\n';
486 mcerr <<
"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n"
487 <<
"the vectors are not of unit length\n";
488 mcerr <<
" pex,pey,pez:\n";
489 mcerr << pex << pey << pez;
490 mcerr <<
"name=" << pname <<
'\n';
494 mcerr <<
"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n";
495 mcerr <<
"wrong direction of pez\n";
496 mcerr <<
" pex,pey,pez:\n";
497 mcerr << pex << pey << pez;
498 mcerr <<
"name=" << pname <<
'\n';
510 Ifile <<
"basis: name=" << b.
name <<
'\n';
512 int indnsave =
indn.
n;
542void point::get_components(ActivePtr<absref_transmit>& aref_tran) {
543 aref_tran.pass(
new absref_transmit(1, &aref));
574 Ifile <<
"abssyscoor::print(l=" << l <<
"): name=" <<
name <<
'\n';
581 Ifile <<
"apiv=NULL\n";
587 Ifile <<
"abas=NULL\n";
616 aref_tran.pass(
new absref_transmit(2,
aref));
624 Ifile <<
"fixsyscoor::print(l=" << l <<
")\n";
627 RegPassivePtr::print(file, l);
634 Ifile <<
"fixsyscoor:\n";
635 f.RegPassivePtr::print(file, 2);
636 f.abssyscoor::print(file, 2);
#define macro_copy_body(type)
DoubleAc cos(const DoubleAc &f)
DoubleAc asin(const DoubleAc &f)
DoubleAc sqrt(const DoubleAc &f)
DoubleAc sin(const DoubleAc &f)
DoubleAc acos(const DoubleAc &f)
#define check_econd11a(a, signb, add, stream)
virtual void turn(const vec &dir, vfloat angle)
virtual void shift(const vec &dir)
virtual void up(const abssyscoor *fasc)
virtual void down(const abssyscoor *fasc)
virtual void print(std::ostream &file, int l) const
virtual const basis * Gabas(void) const =0
virtual const point * Gapiv(void) const =0
virtual void print(std::ostream &file, int l) const
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
static absref absref::* aref[3]
basis switch_xyz(void) const
void Ppiv(const point &fpiv)
static absrefabsref::*[2] aref
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
virtual void print(std::ostream &file, int l) const
void Pbas(const basis &fbas)
virtual void print(std::ostream &file, int l) const
virtual void up(const abssyscoor *fasc)
virtual void shift(const vec &dir)
virtual void down(const abssyscoor *fasc)
void random_conic_vec(double theta)
void shift(const vec &dir)
friend vfloat length(const vec &v)
void down(const basis *fabas)
void random_round_vec(void)
friend wl_inline int check_par(const vec &r1, const vec &r2, vfloat prec)
vec up_new(const basis *fabas_new)
void random_sfer_vec(void)
void up(const basis *fabas_new)
vec down_new(const basis *fabas)
friend wl_inline vec unit_vec(const vec &v)
void turn(const vec &dir, vfloat angle)
vec turn_new(const vec &dir, vfloat angle)
std::ostream & noindent(std::ostream &f)
std::ostream & operator<<(std::ostream &file, const vec &v)
vfloat ang2vec(const vec &r1, const vec &r2)
HepRandomEngine & random_engine
vec project_to_plane(const vec &r, const vec &normal)
vfloat cos2vec(const vec &r1, const vec &r2)
vfloat ang2projvec(const vec &r1, const vec &r2, const vec &normal)
vfloat sin2vec(const vec &r1, const vec &r2)
#define pvecerrorp(string)
#define ApplyAnyFunctionToVecElements(func)
#define pvecerror(string)
int not_apeq(vfloat f1, vfloat f2, vfloat prec=vprecision)