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


C++ VectorXs::transpose方法代码示例

本文整理汇总了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);
}
开发者ID:js4768,项目名称:4167T2M1,代码行数:28,代码来源:PenaltyForce.cpp


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