本文整理汇总了C++中Cylinder::setCylinder方法的典型用法代码示例。如果您正苦于以下问题:C++ Cylinder::setCylinder方法的具体用法?C++ Cylinder::setCylinder怎么用?C++ Cylinder::setCylinder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cylinder
的用法示例。
在下文中一共展示了Cylinder::setCylinder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setUpResult
/*!
* \brief RectifyToVector::setUpResult
* \param cylinder
* \return
*/
bool RectifyToVector::setUpResult(Cylinder &cylinder)
{
//get and check cylinder
if(!this->inputElements.contains(0) || this->inputElements[0].size() != 1){
return false;
}
QPointer<Geometry> geometry = this->inputElements[0].at(0).geometry;
if(geometry.isNull() || !geometry->getIsSolved() || !geometry->hasDirection()){
return false;
}
//get the sense (positive or negative)
double sense = 1.0;
if(this->scalarInputParams.stringParameter.contains("sense")){
if(this->scalarInputParams.stringParameter.value("sense").compare("negative") == 0){
sense = -1.0;
}
}
//get the direction to compare
OiVec r_reference = geometry->getDirection().getVector();
r_reference.normalize();
OiVec r_cylinder = cylinder.getDirection().getVector();
r_cylinder.normalize();
//calculate the angle between both directions
double angle = 0.0;
OiVec::dot(angle, r_reference, r_cylinder);
angle = qAbs(qAcos(angle));
//invert the normal vector if the angle is greater than 90°
if(angle > PI/2.0){
r_cylinder = -1.0 * r_cylinder;
}
//invert the normal vector if sense is negative
r_cylinder = sense * r_cylinder;
//set result
Direction direction = cylinder.getDirection();
direction.setVector(r_cylinder);
cylinder.setCylinder(cylinder.getPosition(), direction, cylinder.getRadius());
return true;
}