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