本文整理汇总了C++中Vector4d::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector4d::normalize方法的具体用法?C++ Vector4d::normalize怎么用?C++ Vector4d::normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector4d
的用法示例。
在下文中一共展示了Vector4d::normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: normal_vector
Vector4d Triangle::normal_vector(const Vector4d &surface) const {
double u, v;
std::tie(u, v) = uvCoords(surface);
Vector4d normal = (1 - u - v) * n1 + u * n2 + v * n3;
normal.normalize();
return normal;
}
示例2: _computeElasticForcesNew
void CSimuVertexRingObj::_computeElasticForcesNew(
const unsigned int timeid, const bool isStatic, const bool needjacobian)
{
//compute the rotation for each vertex
const bool bRecompRot = (timeid%2 == 1);
if (timeid<=1 || bRecompRot){
const bool needquat = false;
updateRotationQuaternionForAllElements(timeid, needquat);
}
else{
//use central difference to update the quaternions
for (int i=0; i<m_nVRingElementCount; i++){
CVertexRingElement &e = m_pVRingElement[i];
Vector4d quat = e.m_quat + e.m_quat - e.m_quat0;
quat.normalize();
e.m_quat0 = e.m_quat;
e.m_quat = quat;
//convert quat to matrix
Quaternion *pquat = (Quaternion*)&e.m_quat.x;
typedef double M33[3][3];
pquat->getRotationMatrix(*((M33*)&e.m_R.x));
}
}
//call the old alg.
const int SKIPSTEP = m_nRotationSkipStep;
m_nRotationSkipStep = INT_MAX-1;
_computeElasticForces(timeid, isStatic, needjacobian);
m_nRotationSkipStep = SKIPSTEP;
/*
//compute forces using the rotation
Vector3d force;
double3x3 jacobian, *pjac=NULL;
const bool FASTSTIFF = (this->m_mtl.getMaterialType()==0);
if (needjacobian) pjac = &jacobian;
for (int i=0; i<m_nEdge; i++){
CSimuEdgeInput& edge = m_pEdge[i];
const int v0=edge.v0, v1=edge.v1;
if (bRecompRot){
//computer averaged rotation of the rod, then save it
const Quaternion *q0 = (const Quaternion *)(&m_pVRingElement[v0].m_quat);
const Quaternion *q1 = (const Quaternion *)(&m_pVRingElement[v1].m_quat);
const Quaternion q = Quaternion::slerp_midpoint(*q0, *q1);
q.getRotationMatrix(*((double(*)[3][3])(&edge.mat)));
}
//apply the rotation for the rod element
const Vector3d& p0 = m_pVertInfo[v0].m_pos;
const Vector3d& p1 = m_pVertInfo[v1].m_pos;
m_pGyrod[i].computeNodalForce(p0, p1, edge.mat, *edge.pMaterial, force, pjac);
//accumulate the force and stiffness
m_pVertInfo[v0].m_force+=force;
m_pVertInfo[v1].m_force-=force;
if (needjacobian)
saveVertSitffMatrixIntoSparseMatrix(v0, v1, *pjac, FASTSTIFF);
}
*/
}
示例3: loadCameraFromFile
TEST(cam_loader, loadCameraFromFile) {
Camera c = loadCameraFromFile("cam_file.cam");
// location
EXPECT_FLOAT_EQ(c.position.orig[0], 4.0);
EXPECT_FLOAT_EQ(c.position.orig[1], 5.0);
EXPECT_FLOAT_EQ(c.position.orig[2], 6.0);
// direction
Vector4d expected = Vector4d(1.0, 0.5, 1.1, 0.0);
expected.normalize();
EXPECT_LT((c.position.dir - expected).norm(), 0.00001) << "direction vector";
// up direction
Vector4d expected_up = Vector4d(1, 2, 3, 0).normalized();
EXPECT_FLOAT_EQ((c.up - expected_up).norm(), 0.0) << "up vector";
// dimensions
EXPECT_DOUBLE_EQ(c.worldWidth, 10) << "world width";
EXPECT_DOUBLE_EQ(c.worldHeight, 20) << "world height";
}