本文整理汇总了C++中kernel::V3D::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ V3D::normalize方法的具体用法?C++ V3D::normalize怎么用?C++ V3D::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kernel::V3D
的用法示例。
在下文中一共展示了V3D::normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detRadius
/**
* This function calculates the exponential contribution to the He3 tube
* efficiency.
* @param spectraIndex :: the current index to calculate
* @param idet :: the current detector pointer
* @throw out_of_range if twice tube thickness is greater than tube diameter
* @return the exponential contribution for the given detector
*/
double He3TubeEfficiency::calculateExponential(
std::size_t spectraIndex,
boost::shared_ptr<const Geometry::IDetector> idet) {
// Get the parameters for the current associated tube
double pressure =
this->getParameter("TubePressure", spectraIndex, "tube_pressure", idet);
double tubethickness =
this->getParameter("TubeThickness", spectraIndex, "tube_thickness", idet);
double temperature = this->getParameter("TubeTemperature", spectraIndex,
"tube_temperature", idet);
double detRadius(0.0);
Kernel::V3D detAxis;
this->getDetectorGeometry(idet, detRadius, detAxis);
double detDiameter = 2.0 * detRadius;
double twiceTubeThickness = 2.0 * tubethickness;
// now get the sin of the angle, it's the magnitude of the cross product of
// unit vector along the detector tube axis and a unit vector directed from
// the sample to the detector center
Kernel::V3D vectorFromSample = idet->getPos() - this->samplePos;
vectorFromSample.normalize();
Kernel::Quat rot = idet->getRotation();
// rotate the original cylinder object axis to get the detector axis in the
// actual instrument
rot.rotate(detAxis);
detAxis.normalize();
// Scalar product is quicker than cross product
double cosTheta = detAxis.scalar_prod(vectorFromSample);
double sinTheta = std::sqrt(1.0 - cosTheta * cosTheta);
const double straight_path = detDiameter - twiceTubeThickness;
if (std::fabs(straight_path - 0.0) < TOL) {
throw std::out_of_range("Twice tube thickness cannot be greater than "
"or equal to the tube diameter");
}
const double pathlength = straight_path / sinTheta;
return EXP_SCALAR_CONST * (pressure / temperature) * pathlength;
}
示例2: exec
//.........这里部分代码省略.........
<< "\n";
// Move in cm for small shifts
g_log.information() << "Move (X) = " << gsl_vector_get(s->x, 0) * 0.01
<< " \n";
g_log.information() << "Move (Y) = " << gsl_vector_get(s->x, 1) * 0.01
<< " \n";
g_log.information() << "Move (Z) = " << gsl_vector_get(s->x, 2) * 0.01
<< " \n";
g_log.information() << "Rotate (X) = " << gsl_vector_get(s->x, 3) << " \n";
g_log.information() << "Rotate (Y) = " << gsl_vector_get(s->x, 4) << " \n";
g_log.information() << "Rotate (Z) = " << gsl_vector_get(s->x, 5) << " \n";
Kernel::V3D CalCenter =
V3D(gsl_vector_get(s->x, 0) * 0.01, gsl_vector_get(s->x, 1) * 0.01,
gsl_vector_get(s->x, 2) * 0.01);
Kernel::V3D Center = detList[det]->getPos() + CalCenter;
int pixmax = detList[det]->xpixels() - 1;
int pixmid = (detList[det]->ypixels() - 1) / 2;
BoundingBox box;
detList[det]->getAtXY(pixmax, pixmid)->getBoundingBox(box);
double baseX = box.xMax();
double baseY = box.yMax();
double baseZ = box.zMax();
Kernel::V3D Base = V3D(baseX, baseY, baseZ) + CalCenter;
pixmid = (detList[det]->xpixels() - 1) / 2;
pixmax = detList[det]->ypixels() - 1;
detList[det]->getAtXY(pixmid, pixmax)->getBoundingBox(box);
double upX = box.xMax();
double upY = box.yMax();
double upZ = box.zMax();
Kernel::V3D Up = V3D(upX, upY, upZ) + CalCenter;
Base -= Center;
Up -= Center;
// Rotate around x
baseX = Base[0];
baseY = Base[1];
baseZ = Base[2];
double deg2rad = M_PI / 180.0;
double angle = gsl_vector_get(s->x, 3) * deg2rad;
Base = V3D(baseX, baseY * cos(angle) - baseZ * sin(angle),
baseY * sin(angle) + baseZ * cos(angle));
upX = Up[0];
upY = Up[1];
upZ = Up[2];
Up = V3D(upX, upY * cos(angle) - upZ * sin(angle),
upY * sin(angle) + upZ * cos(angle));
// Rotate around y
baseX = Base[0];
baseY = Base[1];
baseZ = Base[2];
angle = gsl_vector_get(s->x, 4) * deg2rad;
Base = V3D(baseZ * sin(angle) + baseX * cos(angle), baseY,
baseZ * cos(angle) - baseX * sin(angle));
upX = Up[0];
upY = Up[1];
upZ = Up[2];
Up = V3D(upZ * cos(angle) - upX * sin(angle), upY,
upZ * sin(angle) + upX * cos(angle));
// Rotate around z
baseX = Base[0];
baseY = Base[1];
baseZ = Base[2];
angle = gsl_vector_get(s->x, 5) * deg2rad;
Base = V3D(baseX * cos(angle) - baseY * sin(angle),
baseX * sin(angle) + baseY * cos(angle), baseZ);
upX = Up[0];
upY = Up[1];
upZ = Up[2];
Up = V3D(upX * cos(angle) - upY * sin(angle),
upX * sin(angle) + upY * cos(angle), upZ);
Base.normalize();
Up.normalize();
Center *= 100.0;
// << det+1 << " "
outfile << "5 " << detList[det]->getName().substr(4) << " "
<< detList[det]->xpixels() << " " << detList[det]->ypixels()
<< " " << 100.0 * detList[det]->xsize() << " "
<< 100.0 * detList[det]->ysize() << " "
<< "0.2000"
<< " " << Center.norm() << " ";
Center.write(outfile);
outfile << " ";
Base.write(outfile);
outfile << " ";
Up.write(outfile);
outfile << "\n";
// clean up dynamically allocated gsl stuff
gsl_vector_free(x);
gsl_vector_free(ss);
gsl_multimin_fminimizer_free(s);
// Remove the now-unneeded grouping workspace
AnalysisDataService::Instance().remove(groupWSName);
prog.report(detList[det]->getName());
}
// Closing
outfile.close();
}
示例3: findSkewBasis
/**
* This function calculates the given skew basis vector.
*
* @param basis : The "base" basis vector.
* @param scale : Scale factor for the basis vector.
*/
void vtkDataSetToNonOrthogonalDataSet::findSkewBasis(Kernel::V3D &basis,
double scale) {
basis = m_skewMat * basis;
basis /= scale;
basis.normalize();
}