本文整理汇总了C++中Vector3s::setConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3s::setConstant方法的具体用法?C++ Vector3s::setConstant怎么用?C++ Vector3s::setConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3s
的用法示例。
在下文中一共展示了Vector3s::setConstant方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadDragDampingForces
void TwoDSceneXMLParser::loadDragDampingForces( rapidxml::xml_node<>* node, TwoDScene& twodscene )
{
assert( node != NULL );
int forcenum = 0;
for( rapidxml::xml_node<>* nd = node->first_node("dragdamping"); nd; nd = nd->next_sibling("dragdamping") )
{
Vector3s constforce;
constforce.setConstant(std::numeric_limits<scalar>::signaling_NaN());
// Extract the linear damping coefficient
scalar b = std::numeric_limits<scalar>::signaling_NaN();
if( nd->first_attribute("b") )
{
std::string attribute(nd->first_attribute("b")->value());
if( !stringutils::extractFromString(attribute,b) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of b attribute for dragdamping " << forcenum << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse b attribute for dragdamping " << forcenum << ". Exiting." << std::endl;
exit(1);
}
//std::cout << "x: " << constforce.transpose() << std::endl;
twodscene.insertForce(new DragDampingForce(b));
++forcenum;
}
}
示例2: computeMassAndInertia
void RigidBodySphere::computeMassAndInertia( const scalar& density, scalar& M, Vector3s& CM, Vector3s& I, Matrix33sr& R ) const
{
M = 4.0 * MathDefines::PI<scalar>() * m_r * m_r * m_r / 3.0;
I.setConstant( 2.0 * M * m_r * m_r / 5.0 );
M *= density;
I *= density;
CM.setZero();
R.setIdentity();
}
示例3: loadSimpleGravityForces
void TwoDSceneXMLParser::loadSimpleGravityForces( rapidxml::xml_node<>* node, TwoDScene& twodscene )
{
assert( node != NULL );
// Load each constant force
int forcenum = 0;
for( rapidxml::xml_node<>* nd = node->first_node("simplegravity"); nd; nd = nd->next_sibling("simplegravity") )
{
Vector3s constforce;
constforce.setConstant(std::numeric_limits<scalar>::signaling_NaN());
// Extract the x component of the force
if( nd->first_attribute("fx") )
{
std::string attribute(nd->first_attribute("fx")->value());
if( !stringutils::extractFromString(attribute,constforce.x()) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of fx attribute for constantforce " << forcenum << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse fx attribute for constantforce " << forcenum << ". Exiting." << std::endl;
exit(1);
}
// Extract the y component of the force
if( nd->first_attribute("fy") )
{
std::string attribute(nd->first_attribute("fy")->value());
if( !stringutils::extractFromString(attribute,constforce.y()) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of fy attribute for constantforce " << forcenum << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse fy attribute for constantforce " << forcenum << ". Exiting." << std::endl;
exit(1);
}
// Extract the y component of the force
if( nd->first_attribute("fz") )
{
std::string attribute(nd->first_attribute("fz")->value());
if( !stringutils::extractFromString(attribute,constforce.z()) )
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse value of fz attribute for constantforce " << forcenum << ". Value must be numeric. Exiting." << std::endl;
exit(1);
}
}
else
{
std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse fz attribute for constantforce " << forcenum << ". Exiting." << std::endl;
exit(1);
}
//std::cout << "x: " << constforce.transpose() << std::endl;
twodscene.insertForce(new SimpleGravityForce(constforce));
++forcenum;
}
}