当前位置: 首页>>代码示例>>C++>>正文


C++ kernel::V3D类代码示例

本文整理汇总了C++中mantid::kernel::V3D的典型用法代码示例。如果您正苦于以下问题:C++ V3D类的具体用法?C++ V3D怎么用?C++ V3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了V3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: left

MantidQt::SliceViewer::PeakBoundingBox getPeakBoundingBoxForEllipsoid(
    const std::vector<Mantid::Kernel::V3D> &directions,
    const std::vector<double> &radii,
    const Mantid::Kernel::V3D &originEllipsoid) {
  // Get the length of largest projection onto x,y,z
  auto projectionLengths = getProjectionLengths(directions, radii);

  using namespace MantidQt::SliceViewer;

  // Corners
  EllipsoidPlaneSliceCalculator calc;
  auto zoomOutFactor = calc.getZoomOutFactor();
  const double leftValue =
      originEllipsoid.X() - zoomOutFactor * projectionLengths[0];
  const double rightValue =
      originEllipsoid.X() + zoomOutFactor * projectionLengths[0];
  const double bottomValue =
      originEllipsoid.Y() - zoomOutFactor * projectionLengths[1];
  const double topValue =
      originEllipsoid.Y() + zoomOutFactor * projectionLengths[1];

  Left left(leftValue);
  Right right(rightValue);
  Bottom bottom(bottomValue);
  Top top(topValue);
  SlicePoint slicePoint(originEllipsoid.Z());

  return PeakBoundingBox(left, right, top, bottom, slicePoint);
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:29,代码来源:EllipsoidPlaneSliceCalculator.cpp

示例2:

Mantid::Kernel::V3D
PeakTransform::transformBack(const Mantid::Kernel::V3D &transformed) const {
  // Will have the plots x, y, and z aligned to the correct h, k, l value.
  Mantid::Kernel::V3D originalPeakPosition;
  originalPeakPosition.setX(transformed[m_indexOfPeakX]);
  originalPeakPosition.setY(transformed[m_indexOfPeakY]);
  originalPeakPosition.setZ(transformed[m_indexOfPeakZ]);
  return originalPeakPosition;
}
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:PeakTransform.cpp

示例3: calcSize

/** Calculate the size of the detector in U/V
*
* @param udet :: UwrappedDetector struct to calculate the size for. udet's size
*fields
* are updated by this method.
*/
void UnwrappedSurface::calcSize(UnwrappedDetector &udet) {
  // U is the horizontal axis on the screen
  const Mantid::Kernel::V3D U(-1, 0, 0);
  // V is the vertical axis on the screen
  const Mantid::Kernel::V3D V(0, 1, 0);

  // find the detector's rotation
  Mantid::Kernel::Quat R;
  this->rotate(udet, R);

  Mantid::Geometry::BoundingBox bbox = udet.detector->shape()->getBoundingBox();
  Mantid::Kernel::V3D scale = udet.detector->getScaleFactor();

  // sizes of the detector along each 3D axis
  Mantid::Kernel::V3D size = bbox.maxPoint() - bbox.minPoint();
  size *= scale;

  Mantid::Kernel::V3D s1(size);
  Mantid::Kernel::V3D s2 = size + Mantid::Kernel::V3D(-size.X(), 0, 0) -
                           Mantid::Kernel::V3D(size.X(), 0, 0);
  Mantid::Kernel::V3D s3 = size + Mantid::Kernel::V3D(0, -size.Y(), 0) -
                           Mantid::Kernel::V3D(0, size.Y(), 0);
  // rotate the size vectors to get the dimensions along axes U and V
  R.rotate(s1);
  R.rotate(s2);
  R.rotate(s3);

  // get the larges projection to the U axis which is the visible width
  double d = fabs(s1.scalar_prod(U));
  udet.width = d;
  d = fabs(s2.scalar_prod(U));
  if (d > udet.width)
    udet.width = d;
  d = fabs(s3.scalar_prod(U));
  if (d > udet.width)
    udet.width = d;

  // get the larges projection to the V axis which is the visible height
  d = fabs(s1.scalar_prod(V));
  udet.height = d;
  d = fabs(s2.scalar_prod(V));
  if (d > udet.height)
    udet.height = d;
  d = fabs(s3.scalar_prod(V));
  if (d > udet.height)
    udet.height = d;

  // apply the scale factors
  udet.width *= udet.uscale;
  udet.height *= udet.vscale;

  // don't let them be too large
  if (udet.width > m_width_max)
    m_width_max = udet.width;
  if (udet.height > m_height_max)
    m_height_max = udet.height;
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:63,代码来源:UnwrappedSurface.cpp

示例4: project

/** Convert physical position to UV projection
 *
 * @param pos :: position in 3D
 * @param u :: set to U
 * @param v :: set to V
 * @param uscale :: scaling for u direction
 * @param vscale :: scaling for v direction
 */
void UnwrappedCylinder::project(const Mantid::Kernel::V3D &pos, double &u,
                                double &v, double &uscale,
                                double &vscale) const {
  // projection to cylinder axis
  v = pos.scalar_prod(m_zaxis);
  double x = pos.scalar_prod(m_xaxis);
  double y = pos.scalar_prod(m_yaxis);
  u = applyUCorrection(-atan2(y, x));

  uscale = 1. / sqrt(x * x + y * y);
  vscale = 1.;
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:20,代码来源:UnwrappedCylinder.cpp

示例5: rotate

void UnwrappedSphere::rotate(const UnwrappedDetector &udet,
                             Mantid::Kernel::Quat &R) const {
  // rotation from the global axes to those where
  // the z axis points to the detector
  Mantid::Kernel::Quat R1;
  // direction in which to look: from sample to detector
  Mantid::Kernel::V3D eye;
  eye = m_pos - udet.detector->getPos();
  if (!eye.nullVector()) {
    InstrumentActor::rotateToLookAt(eye, m_zaxis, R1);
  }
  // add detector's own rotation
  R = R1 * udet.detector->getRotation();
}
开发者ID:liyulun,项目名称:mantid,代码行数:14,代码来源:UnwrappedSphere.cpp

示例6: project

/** Convert physical position to UV projection
 *
 * @param u :: set to U
 * @param v :: set to V
 * @param uscale :: scaling for u direction
 * @param vscale :: scaling for v direction
 * @param pos :: position in 3D
 */
void UnwrappedSphere::project(double & u, double & v, double & uscale, double & vscale, const Mantid::Kernel::V3D & pos) const
{
  // projection to cylinder axis
  v = pos.scalar_prod(m_zaxis);
  double x = pos.scalar_prod(m_xaxis);
  double y = pos.scalar_prod(m_yaxis);

  double r = sqrt(x*x+y*y+v*v);
  uscale = 1./sqrt(x*x+y*y);
  vscale = 1./r;

  u = applyUCorrection( -atan2(y,x) );
  v = -acos(v/r);
}
开发者ID:trnielsen,项目名称:mantid,代码行数:22,代码来源:UnwrappedSphere.cpp

示例7: getPeakInformation

/** Get peak information from peaks workspace
 * @return
 */
void IntegratePeaksCWSD::getPeakInformation() {
  m_vecPeaks = m_peaksWS->getPeaks();
  size_t numpeaks = m_vecPeaks.size();
  for (size_t ipeak = 0; ipeak < numpeaks; ++ipeak) {
    DataObjects::Peak &peak = m_vecPeaks[ipeak];
    int run_number = peak.getRunNumber();
    Mantid::Kernel::V3D qsample = peak.getQSampleFrame();
    m_runPeakCenterMap.insert(std::make_pair(run_number, qsample));

    // set up the data structure to store integrated peaks' counts
    m_runPeakCountsMap.insert(std::make_pair(run_number, 0.));

    g_log.information() << "From peak workspace: peak " << ipeak
                        << " Center (Qsample) = " << qsample.toString() << "\n";
  }
}
开发者ID:mducle,项目名称:mantid,代码行数:19,代码来源:IntegratePeaksCWSD.cpp

示例8: weightAt

  /**
 Calculate the weight at distance from epicenter. Uses linear scaling based on distance from epicenter.
 @param distance : absolute distance from epicenter
 @return weighting
 */
 double GaussianWeightingnD::weightAt(const Mantid::Kernel::V3D& distance)
 {
   /*
   distance.norm() = r
   r/R provides normalisation
   */
   double normalisedDistance = distance.norm()/m_cutOff; //Ensures 1 at the edges and zero in the center no matter what the units are
   return calculateGaussian(normalisedDistance*normalisedDistance);
 }
开发者ID:AlistairMills,项目名称:mantid,代码行数:14,代码来源:WeightingStrategy.cpp

示例9: generateRotationTo

/**
 * Generate the rotation matrix to rotate to this point.
 * @param a :: The x mouse coordinate
 * @param b :: The y mouse coordinate
 */
void Viewport::generateRotationTo(int a,int b)
{
  Mantid::Kernel::V3D newpoint;
  projectOnSphere( a, b, newpoint );
  Mantid::Kernel::V3D diff( m_lastpoint );
  // Difference between old point and new point
  diff -= newpoint;
  // Angle is given in degrees as the dot product of the two vectors
  double angle = m_rotationspeed * newpoint.angle( m_lastpoint );
  diff = m_lastpoint.cross_prod( newpoint );
  // Create a quaternion from the angle and vector direction
  Mantid::Kernel::Quat temp( angle, diff );
  // Left multiply
  temp *= m_quaternion;
  // Assignment of _quaternion
  m_quaternion( temp );
  // Get the corresponding OpenGL rotation matrix
  m_quaternion.GLMatrix( &m_rotationmatrix[0] );
}
开发者ID:jkrueger1,项目名称:mantid,代码行数:24,代码来源:Viewport.cpp

示例10: draw

/**
* Implementation of rendering Sample.
*/
void SampleActor::draw(bool picking) const {
  if (!picking && isVisible()) {
    OpenGLError::check("SampleActor::draw()");
    glPushAttrib(GL_ENABLE_BIT);
    GLboolean hasLight0;
    glGetBooleanv(GL_LIGHT0, &hasLight0);
    if (hasLight0) {
      glEnable(GL_LIGHTING);
    }
    glPushMatrix();
    m_color.paint();
    Mantid::Kernel::V3D pos = m_samplePos->getPos();
    glTranslated(pos.X(), pos.Y(), pos.Z());
    m_sample.getShape().draw();
    glPopMatrix();
    glPopAttrib();
    OpenGLError::check("SampleActor::draw()");
  }
}
开发者ID:liyulun,项目名称:mantid,代码行数:22,代码来源:SampleActor.cpp

示例11: getSolutionForEllipsoid

SliceEllipseInfo EllipsoidPlaneSliceCalculator::getSolutionForEllipsoid(
    const Kernel::Matrix<double> &m, double zPlane,
    Mantid::Kernel::V3D originEllipsoid) const {
  // Shift the z value into a suitable frame
  const double z = zPlane - originEllipsoid.Z();

  // Setup the A matrix
  Mantid::Kernel::DblMatrix A;
  A.setMem(2, 2);
  const std::vector<double> ARow0 = {m[0][0], m[0][1]};
  const std::vector<double> ARow1 = {m[0][1], m[1][1]};
  A.setRow(0, ARow0);
  A.setRow(1, ARow1);

  // Setup the inverse Matrix of A
  Mantid::Kernel::DblMatrix AInverse;
  const double detA = A.determinant();
  AInverse.setMem(2, 2);
  const std::vector<double> AInverseRow0 = {m[1][1] / detA, -m[0][1] / detA};
  const std::vector<double> AInverseRow1 = {-m[0][1] / detA, m[0][0] / detA};
  AInverse.setRow(0, AInverseRow0);
  AInverse.setRow(1, AInverseRow1);

  // Setup the B vector
  Mantid::Kernel::DblMatrix B;
  std::vector<double> BColumn = {m[0][2], m[1][2]};
  B.setMem(2, 1);
  B.setColumn(0, BColumn);
  B *= 2 * z;

  // Setip the Transpose B vector
  Mantid::Kernel::DblMatrix BT;
  std::vector<double> BTRow = {m[0][2], m[1][2]};
  BT.setMem(1, 2);
  BT.setRow(0, BTRow);
  BT *= 2 * z;

  // Setup the C factor
  const double c = m[2][2] * std::pow(z, 2);

  // Get the origin
  const auto origin = getOrigin(AInverse, B, originEllipsoid, z);

  // Get the radii + directions
  const auto eigenSystem = getAxesInformation(A, AInverse, B, BT, c);

  // Get angle. If we have a circle then the angle is 0 (we want to avoid a
  // divergence here)
  const auto isCircle = checkIfIsCircle(m);
  const double angle = isCircle ? 0.0 : getAngle(eigenSystem.majorAxis);

  return SliceEllipseInfo(origin, eigenSystem.majorRadius,
                          eigenSystem.minorRadius, angle);
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:54,代码来源:EllipsoidPlaneSliceCalculator.cpp

示例12: updateDataCache

    void QPeaksTableModel::updateDataCache(const Mantid::Geometry::IPeak& peak, const int row) const
    {
      // if the index is what is already cached just return
      if (row == m_dataCachePeakIndex)
        return;

      // generate the cache
      m_dataCache.clear();
      m_dataCache.push_back(QString::number(peak.getRunNumber()));
      m_dataCache.push_back(QString::number(peak.getDetectorID()));
      m_dataCache.push_back(QString::number(peak.getH(), 'f', m_hklPrec));
      m_dataCache.push_back(QString::number(peak.getK(), 'f', m_hklPrec));
      m_dataCache.push_back(QString::number(peak.getL(), 'f', m_hklPrec));
      m_dataCache.push_back(QString::number(peak.getWavelength(), 'f', 4));
      double eI = peak.getInitialEnergy();
      double eF = peak.getFinalEnergy();
      m_dataCache.push_back(QString::number(eI, 'f', 4));
      m_dataCache.push_back(QString::number(eF, 'f', 4));
      m_dataCache.push_back(QString::number(eI - eF, 'f', 4));
      m_dataCache.push_back(QString::number(peak.getTOF(), 'f', 1));
      m_dataCache.push_back(QString::number(peak.getDSpacing(), 'f', 4));
      double intensity = peak.getIntensity();
      double sigma = peak.getSigmaIntensity();
      m_dataCache.push_back(QString::number(intensity, 'f', 1));
      m_dataCache.push_back(QString::number(sigma, 'f', 1));
      m_dataCache.push_back(QString::number(intensity/sigma, 'f', 2));
      m_dataCache.push_back(QString::number(peak.getBinCount(), 'g', 2));
      m_dataCache.push_back(QString(peak.getBankName().c_str()));
      m_dataCache.push_back(QString::number(peak.getRow()));
      m_dataCache.push_back(QString::number(peak.getCol()));

      const QString COMMA(",");

      const Mantid::Kernel::V3D qlab = peak.getQLabFrame();
      m_dataCache.push_back(QString::number(qlab.X(), 'f', 4) + COMMA + QString::number(qlab.Y(), 'f', 4) + COMMA + QString::number(qlab.Z(), 'f', 4));

      const Mantid::Kernel::V3D qsample = peak.getQSampleFrame();
      m_dataCache.push_back(QString::number(qsample.X(), 'f', 4) + COMMA + QString::number(qsample.Y(), 'f', 4) + COMMA + QString::number(qsample.Z(), 'f', 4));
    }
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:39,代码来源:QPeaksTableModel.cpp

示例13: setProjection

/**
 * Convenience overload.
 * 
 * @param minBounds :: Near-bottom-left corner of the scene.
 * @param maxBounds :: Far-top-right corner of the scene.
 * @param type :: Projection type: ORTHO or PERSPECTIVE. PERSPECTIVE isn't fully implemented
 */
void Viewport::setProjection(const Mantid::Kernel::V3D& minBounds, const Mantid::Kernel::V3D& maxBounds, ProjectionType type)
{
  double radius = minBounds.norm();
  double tmp = maxBounds.norm();
  if (tmp > radius) radius = tmp;

  setProjection( minBounds.X(), maxBounds.X(), minBounds.Y(), maxBounds.Y(), -radius, radius, type );
}
开发者ID:jkrueger1,项目名称:mantid,代码行数:15,代码来源:Viewport.cpp

示例14: rotateToLookAt

/**
 * Calculate a rotation to look in a particular direction.
 *
 * @param eye :: A direction to look in
 * @param up :: A vector showing the 'up' direction after the rotation. It doesn't have to be normal to eye
 *   just non-collinear. If up is collinear to eye the actual 'up' direction is undefined.
 * @param R :: The result rotation.
 */
void InstrumentActor::rotateToLookAt(const Mantid::Kernel::V3D &eye, const Mantid::Kernel::V3D &up, Mantid::Kernel::Quat &R)
{
    if ( eye.nullVector() )
    {
        throw std::runtime_error("The eye vector is null in InstrumentActor::rotateToLookAt.");
    }

    // Basis vectors of the OpenGL reference frame. Z points into the screen, Y points up.
    const Mantid::Kernel::V3D X(1,0,0);
    const Mantid::Kernel::V3D Y(0,1,0);
    const Mantid::Kernel::V3D Z(0,0,1);

    Mantid::Kernel::V3D x,y,z;
    z = eye;
    z.normalize();
    y = up;
    x = y.cross_prod(z);
    if (x.nullVector())
    {
        // up || eye
        if ( z.X() != 0.0 )
        {
            x.setY(1.0);
        }
        else if ( z.Y() != 0.0 )
        {
            x.setZ(1.0);
        }
        else
        {
            x.setX(1.0);
        }
    }
    x.normalize();
    y = z.cross_prod(x);

    BasisRotation(x,y,z,X,Y,Z,R);
}
开发者ID:stothe2,项目名称:mantid,代码行数:46,代码来源:InstrumentActor.cpp

示例15: checkIfCutExists

/**
 * Check if a cut with the ellipsoid is possible at all
 * @param directions: the three ellipsoid directions
 * @param radii: the ellipsoid radii
 * @param originEllipsoid: the origin of the ellipsoid
 * @param zPlane: the z plane value
 * @return true if the a cut exists, else false
 */
bool checkIfCutExists(const std::vector<Mantid::Kernel::V3D> &directions,
                      const std::vector<double> &radii,
                      const Mantid::Kernel::V3D &originEllipsoid,
                      double zPlane) {
  // Translate into ellipsoid
  const double z = zPlane - originEllipsoid.Z();

  bool hasCut = false;
  // For each axis check if the z point is between the z values of the
  // axis endpoints
  int counter = 0;
  for (const auto &direction : directions) {
    const auto endpoint1 = direction[2] * radii[counter];
    const auto endpoint2 = -1 * direction[2] * radii[counter];

    if (isBetweenEndpoints(endpoint1, endpoint2, z)) {
      hasCut = true;
      break;
    }
    ++counter;
  }

  return hasCut;
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:32,代码来源:EllipsoidPlaneSliceCalculator.cpp


注:本文中的mantid::kernel::V3D类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。