本文整理汇总了C++中Coord::dotProduct方法的典型用法代码示例。如果您正苦于以下问题:C++ Coord::dotProduct方法的具体用法?C++ Coord::dotProduct怎么用?C++ Coord::dotProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coord
的用法示例。
在下文中一共展示了Coord::dotProduct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mMouseRotate
//========================================================================================
void MouseSelectionEditor::mMouseRotate(double newX, double newY, GlMainWidget *glMainWidget) {
// qWarning() << __PRETTY_FUNCTION__ << endl;
if (operation == ROTATE_Z) {
Coord curPos(newX, newY, 0);
Coord vCS = glMainWidget->screenToViewport(editPosition) - editCenter;
vCS /= vCS.norm();
Coord vCP = glMainWidget->screenToViewport(curPos) - editCenter;
vCP /= vCP.norm();
float sign = (vCS ^ vCP)[2];
sign /= fabs(sign);
double cosalpha = vCS.dotProduct(vCP);
double deltaAngle = sign * acos(cosalpha);
Observable::holdObservers();
initProxies(glMainWidget);
_graph->pop();
_graph->push();
double degAngle = (deltaAngle * 180.0 / M_PI);
// rotate layout
if (mode == COORD_AND_SIZE || mode == COORD) {
Coord center(editLayoutCenter);
center *= -1.;
Iterator<node> *itN = _selection->getNodesEqualTo(true, _graph);
Iterator<edge> *itE = _selection->getEdgesEqualTo(true, _graph);
_layout->translate(center, itN, itE);
delete itN;
delete itE;
itN = _selection->getNodesEqualTo(true, _graph);
itE = _selection->getEdgesEqualTo(true, _graph);
_layout->rotateZ(-degAngle, itN, itE);
delete itN;
delete itE;
center *= -1.;
itN = _selection->getNodesEqualTo(true, _graph);
itE = _selection->getEdgesEqualTo(true, _graph);
_layout->translate(center, itN, itE);
delete itN;
delete itE;
}
if (mode == COORD_AND_SIZE || mode == SIZE) {
for (auto n : _selection->getNodesEqualTo(true, _graph)) {
double rotation = _rotation->getNodeValue(n);
_rotation->setNodeValue(n, rotation - degAngle);
}
}
Observable::unholdObservers();
} else {
double initDelta, delta, cosa;
double xAngle = 0, yAngle = 0;
double nbPI = 0;
delta = abs(glMainWidget->screenToViewport(newX - editPosition[0]));
if (delta > abs(glMainWidget->screenToViewport(newY - editPosition[1]))) {
initDelta = abs(editCenter[0] - glMainWidget->screenToViewport(editPosition[0]));
nbPI = floor(delta / (2. * initDelta));
delta -= nbPI * 2. * initDelta;
cosa = (initDelta - delta) / initDelta;
yAngle = (acos(cosa) + (nbPI * M_PI)) * 180.0 / M_PI;
} else {
delta = abs(glMainWidget->screenToViewport(newY - editPosition[1]));
initDelta = abs(editCenter[1] - glMainWidget->screenToViewport(editPosition[1]));
nbPI = floor(delta / (2. * initDelta));
delta -= nbPI * 2. * initDelta;
cosa = (initDelta - delta) / initDelta;
xAngle = (acos(cosa) + (nbPI * M_PI)) * 180.0 / M_PI;
}
Observable::holdObservers();
initProxies(glMainWidget);
_graph->pop();
_graph->push();
Coord center(editLayoutCenter);
center *= -1.;
Iterator<node> *itN = _selection->getNodesEqualTo(true, _graph);
Iterator<edge> *itE = _selection->getEdgesEqualTo(true, _graph);
_layout->translate(center, itN, itE);
delete itN;
delete itE;
itN = _selection->getNodesEqualTo(true, _graph);
itE = _selection->getEdgesEqualTo(true, _graph);
if (yAngle > xAngle)
_layout->rotateY(yAngle, itN, itE);
else
_layout->rotateX(xAngle, itN, itE);
delete itN;
//.........这里部分代码省略.........