本文整理汇总了C++中VectorXs::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorXs::transpose方法的具体用法?C++ VectorXs::transpose怎么用?C++ VectorXs::transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorXs
的用法示例。
在下文中一共展示了VectorXs::transpose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addParticleHalfplaneGradEToTotal
// Adds the gradient of the penalty potential (-1 * force) for a particle-
// half-plane pair to the total.
// Read the positions of the particle from the input variable x.
// Inputs:
// x: The positions of the particles in the scene.
// vidx: The index of the particle.
// pidx: The index of the half-plane, i.e. the position and normal vectors
// for the half-plane can be retrieved by calling
// m_scene.getHalfplane(pidx).
// Outputs:
// gradE: The total gradient of the penalty force. *ADD* the particle-
// half-plane gradient to this total gradient.
void PenaltyForce::addParticleHalfplaneGradEToTotal(const VectorXs &x, int vidx, int pidx, VectorXs &gradE)
{
VectorXs x1 = x.segment<2>(2*vidx);
VectorXs nh = m_scene.getHalfplane(pidx).second;
VectorXs px = m_scene.getHalfplane(pidx).first;
// your implementation here
Vector2s n = (px-x1).dot(nh)/nh.squaredNorm()*nh;
Vector2s nhat = n/n.norm();
scalar r1 = m_scene.getRadius(vidx);
if(n.norm()>r1+m_thickness) return;
Matrix2s gradn = -nh*nh.transpose()/nh.squaredNorm();
Vector2s gradV = m_k*(n.norm()-r1-m_thickness)*gradn.transpose()*nhat;
gradE(2*vidx) += gradV(0);
gradE(2*vidx+1) += gradV(1);
}