本文整理汇总了C++中kernel::V3D::cross_prod方法的典型用法代码示例。如果您正苦于以下问题:C++ V3D::cross_prod方法的具体用法?C++ V3D::cross_prod怎么用?C++ V3D::cross_prod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kernel::V3D
的用法示例。
在下文中一共展示了V3D::cross_prod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: localPointInCylinder
/**
* Return a local point in a cylinder shape
*
* @param basis a basis vector
* @param alongAxis symmetry axis vector of a cylinder
* @param polarAngle a polar angle (in radians) of a point in a cylinder
* @param radialLength radial position of point in a cylinder
* @return a local point inside the cylinder
*/
Kernel::V3D localPointInCylinder(const Kernel::V3D &basis,
const Kernel::V3D &alongAxis,
double polarAngle, double radialLength) {
// Use basis to get a second perpendicular vector to define basis2
Kernel::V3D basis2;
if (basis.X() == 0) {
basis2.setX(1.);
} else if (basis.Y() == 0) {
basis2.setY(1.);
} else if (basis.Z() == 0) {
basis2.setZ(1.);
} else {
basis2.setX(-basis.Y());
basis2.setY(basis.X());
basis2.normalize();
}
const Kernel::V3D basis3{basis.cross_prod(basis2)};
const Kernel::V3D localPoint{
((basis2 * std::cos(polarAngle) + basis3 * std::sin(polarAngle)) *
radialLength) +
alongAxis};
return localPoint;
}
示例2: volume
/**
* Calculate volume.
* @return The volume.
*/
double MeshObject::volume() const {
// Select centre of bounding box as centre point.
// For each triangle calculate the signed volume of
// the tetrahedron formed by the triangle and the
// centre point. Then add to total.
BoundingBox bb = getBoundingBox();
double cX = 0.5 * (bb.xMax() + bb.xMin());
double cY = 0.5 * (bb.yMax() + bb.yMin());
double cZ = 0.5 * (bb.zMax() + bb.zMin());
Kernel::V3D centre(cX, cY, cZ);
double volumeTimesSix(0.0);
Kernel::V3D vertex1, vertex2, vertex3;
for (size_t i = 0; getTriangle(i, vertex1, vertex2, vertex3); ++i) {
Kernel::V3D a = vertex1 - centre;
Kernel::V3D b = vertex2 - centre;
Kernel::V3D c = vertex3 - centre;
volumeTimesSix += a.scalar_prod(b.cross_prod(c));
}
return volumeTimesSix / 6.0;
}