本文整理汇总了C++中mantid::kernel::V3D::cross_prod方法的典型用法代码示例。如果您正苦于以下问题:C++ V3D::cross_prod方法的具体用法?C++ V3D::cross_prod怎么用?C++ V3D::cross_prod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid::kernel::V3D
的用法示例。
在下文中一共展示了V3D::cross_prod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BasisRotation
/**
* Find a rotation from one orthonormal basis set (Xfrom,Yfrom,Zfrom) to
* another orthonormal basis set (Xto,Yto,Zto). Both sets must be right-handed
* (or same-handed, I didn't check). The method doesn't check the sets for orthogonality
* or normality. The result is a rotation quaternion such that:
* R.rotate(Xfrom) == Xto
* R.rotate(Yfrom) == Yto
* R.rotate(Zfrom) == Zto
* @param Xfrom :: The X axis of the original basis set
* @param Yfrom :: The Y axis of the original basis set
* @param Zfrom :: The Z axis of the original basis set
* @param Xto :: The X axis of the final basis set
* @param Yto :: The Y axis of the final basis set
* @param Zto :: The Z axis of the final basis set
* @param R :: The output rotation as a quaternion
* @param out :: Debug printout flag
*/
void InstrumentActor::BasisRotation(const Mantid::Kernel::V3D& Xfrom,
const Mantid::Kernel::V3D& Yfrom,
const Mantid::Kernel::V3D& Zfrom,
const Mantid::Kernel::V3D& Xto,
const Mantid::Kernel::V3D& Yto,
const Mantid::Kernel::V3D& Zto,
Mantid::Kernel::Quat& R,
bool out
)
{
// Find transformation from (X,Y,Z) to (XX,YY,ZZ)
// R = R1*R2*R3, where R1, R2, and R3 are Euler rotations
// std::cerr<<"RCRotation-----------------------------\n";
// std::cerr<<"From "<<Xfrom<<Yfrom<<Zfrom<<'\n';
// std::cerr<<"To "<<Xto<<Yto<<Zto<<'\n';
double sZ = Zfrom.scalar_prod(Zto);
if (fabs(sZ - 1) < m_tolerance) // vectors the same
{
double sX = Xfrom.scalar_prod(Xto);
if (fabs(sX - 1) < m_tolerance)
{
R = Mantid::Kernel::Quat();
}
else if (fabs(sX + 1) < m_tolerance)
{
R = Mantid::Kernel::Quat(180,Zfrom);
}
else
{
R = Mantid::Kernel::Quat(Xfrom,Xto);
}
}
else if(fabs(sZ + 1) < m_tolerance) // rotated by 180 degrees
{
if (fabs(Xfrom.scalar_prod(Xto)-1) < m_tolerance)
{
R = Mantid::Kernel::Quat(180.,Xfrom);
}
else if (fabs(Yfrom.scalar_prod(Yto)-1) < m_tolerance)
{
R = Mantid::Kernel::Quat(180.,Yfrom);
}
else
{
R = Mantid::Kernel::Quat(180.,Xto)*Mantid::Kernel::Quat(Xfrom,Xto);
}
}
else
{
// Rotation R1 of system (X,Y,Z) around Z by alpha
Mantid::Kernel::V3D X1;
Mantid::Kernel::Quat R1;
X1 = Zfrom.cross_prod(Zto);
X1.normalize();
double sX = Xfrom.scalar_prod(Xto);
if (fabs(sX - 1) < m_tolerance)
{
R = Mantid::Kernel::Quat(Zfrom,Zto);
return;
}
sX = Xfrom.scalar_prod(X1);
if (fabs(sX - 1) < m_tolerance)
{
R1 = Mantid::Kernel::Quat();
}
else if (fabs(sX + 1) < m_tolerance) // 180 degree rotation
{
R1 = Mantid::Kernel::Quat(180.,Zfrom);
}
else
{
R1 = Mantid::Kernel::Quat(Xfrom,X1);
}
if (out)
std::cerr<<"R1="<<R1<<'\n';
// Rotation R2 around X1 by beta
Mantid::Kernel::Quat R2(Zfrom,Zto); // vectors are different
//.........这里部分代码省略.........