本文整理汇总了C++中TVector3::RotateX方法的典型用法代码示例。如果您正苦于以下问题:C++ TVector3::RotateX方法的具体用法?C++ TVector3::RotateX怎么用?C++ TVector3::RotateX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVector3
的用法示例。
在下文中一共展示了TVector3::RotateX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rotate_3vector
void rotate_3vector(void){
PI = TMath::Pi();
TVector3 beam = TVector3(0.,0.,1.);
TVector3 scat = TVector3(0.2,0.4,1.);
std::cout << "beam x : " << beam.x() << std::endl;
std::cout << "beam y : " << beam.y() << std::endl;
std::cout << "beam z : " << beam.z() << std::endl;
std::cout << "scat x : " << scat.x() << std::endl;
std::cout << "scat y : " << scat.y() << std::endl;
std::cout << "scat z : " << scat.z() << std::endl;
double bx=beam.x();
double by=beam.y();
double bz=beam.z();
double sx=scat.x();
double sy=scat.y();
double sz=scat.z();
double theta = acos((bx*sx + by*sy + bz*sz)/sqrt(bx*bx + by*by + bz*bz)/sqrt(sx*sx + sy*sy + sz*sz));
double theta_ = acos(sz/sqrt(sx*sx+sy*sy+sz*sz));
std::cout << "theta : " << theta << std::endl;
std::cout << "theta_ : " << theta_ << std::endl;
TVector3 beam2 = TVector3(0, 1, 0);
double bx2=beam2.x();
double by2=beam2.y();
double bz2=beam2.z();
std::cout << "beam2 x (nom) : " << beam2.x()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
std::cout << "beam2 y (nom) : " << beam2.y()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
std::cout << "beam2 z (nom) : " << beam2.z()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
double theta_tmp = - atan(by2/sqrt(bx2*bx2 + bz2*bz2));
double phi_tmp = atan2(bx2, bz2);
std::cout << "theta_tmp : " << theta_tmp << std::endl;
std::cout << "phi_tmp : " << phi_tmp << std::endl;
beam.RotateX(theta_tmp);
beam.RotateY(phi_tmp);
scat.RotateX(theta_tmp);
scat.RotateY(phi_tmp);
bx=beam.x();
by=beam.y();
bz=beam.z();
sx=scat.x();
sy=scat.y();
sz=scat.z();
std::cout << "roteta beam x : " << bx << std::endl;
std::cout << "roteta beam y : " << by << std::endl;
std::cout << "roteta beam z : " << bz << std::endl;
std::cout << "roteta scat x : " << sx << std::endl;
std::cout << "roteta scat y : " << sy << std::endl;
std::cout << "roteta scat z : " << sz << std::endl;
double theta_rotate = acos((bx*sx + by*sy + bz*sz)/sqrt(bx*bx + by*by + bz*bz)/sqrt(sx*sx + sy*sy + sz*sz));
std::cout << "===========================" << std::endl;
std::cout << "theta : " << theta << std::endl;
std::cout << "theta_rotate : " << theta_rotate << std::endl;
}