本文整理汇总了C++中ofPoint::distance方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPoint::distance方法的具体用法?C++ ofPoint::distance怎么用?C++ ofPoint::distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPoint
的用法示例。
在下文中一共展示了ofPoint::distance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void ttRopeBasic::update(ofPoint AccFrc,ofPoint StartPos){
accFrc = AccFrc;
startPos = StartPos;
endPos = StartPos;
if(num_char == 0){
if (accFrc.y<-0.15){
endPos.y += ofMap(accFrc.y, -0.15, -0.6, 0, 1024-endPos.y, true);
length = StartPos.distance(endPos);
bFixedMove = true;
}else{
endPos.y = StartPos.y;
length = StartPos.distance(endPos);
bFixedMove = false;
}
}
if (num_char == 1) {
if (accFrc.y>0.15) {
endPos.y -= ofMap(accFrc.y, 0.15, 0.6, 0, endPos.y,true);
length = StartPos.distance(endPos);
bFixedMove = true;
}else{
endPos.y = StartPos.y;
length = StartPos.distance(endPos);
bFixedMove = false;
}
}
getPos = startPos;
getLength = length;
}
示例2: getLineEndPoints
//--------
void ofApp::getLineEndPoints(ofxCvBlob blob, ofPoint &start, ofPoint &end) {
start = blob.pts[0];
end = blob.pts[1];
float maxDist = start.distance(end);
for(int i=0; i < blob.nPts; i++){
if(blob.pts[i].distance(start) > maxDist) {
end = blob.pts[i];
maxDist = start.distance(end);
}
}
}
示例3: mousePressed
void mousePressed(int x, int y, int button) {
x /= globalScale;
y /= globalScale;
canvas.mousePressed(x, y, button);
side.mousePressed(x, y, button);
// cout << btnHelpPos.distance(ofPoint(x,y)) << endl;
if (btnHelpPos.distance(ofPoint(x,y))<btnHelp.width/2) showHelp();
if (btnNew.hitTest(x,y)) { files.cur=-1; canvas.clear(); files.unloadFile(); }
if (btnSave.hitTest(x,y)) files.save();
if (btnLoadPrevious.hitTest(x,y)) files.loadPrevious();
if (btnLoadNext.hitTest(x,y)) files.loadNext();
if (btnPrint.hitTest(x,y)) print();
if (btnStop.hitTest(x,y)) stop();
if (btnOops.hitTest(x,y)) { btnOops.selected=true; }
if (btnZoomIn.hitTest(x,y)) btnZoomIn.selected=true;
if (btnZoomOut.hitTest(x,y)) btnZoomOut.selected=true;
if (btnHigher.hitTest(x,y)) btnHigher.selected=true;
if (btnLower.hitTest(x,y)) btnLower.selected=true;
if (btnTwistLeft.hitTest(x,y)) btnTwistLeft.selected=true;
if (btnTwistRight.hitTest(x,y)) btnTwistRight.selected=true;
if (shapeButtons.inside(x,y)) {
int index = ofNormalize(x,shapeButtons.x,shapeButtons.x+shapeButtons.width) * shapeString.size();
side.setShape(shapeString.at(index));
}
}
示例4: getGetClosePath
ofPoint SuperGlyph::getGetClosePath(ofPoint _pos){
ofPoint normal;
ofPoint target;
float minDist = 1000000;
for (int i = 0; i < insidePath.getVertices().size()-1; i++) {
ofPoint a = insidePath.getVertices()[i];
ofPoint b = insidePath.getVertices()[i+1];
ofPoint normalPoint = getNormalPoint(_pos, a, b);
if (normalPoint.x < a.x || normalPoint.x > b.x) {
normalPoint = b;
}
float distance = _pos.distance(normalPoint);
if (distance < minDist) {
minDist = distance;
normal = normalPoint;
ofPoint dir = b - a;
dir.normalize();
dir *= 10;
target = normalPoint;
target += dir;
}
}
return target;
}
示例5: addParticle
void Communitas::addParticle(ofPoint _pos, int _n) {
if ( universe.inside( _pos ) ){
timer = 0;
int nLnk = 0;
for (int i = pAct.size()-1; i >= 0 ; i--){
if (nLnk == 0)
if (pAct[i]->idN == _n)
nLnk = i;
if ( _pos.distance(pAct[i]->loc) <= 40)
pAct[i]->alpha = 255;
}
LineDot * dot = new LineDot(_n, &universe, _pos ,false);
if ( nLnk > 0)
dot->setLnk(pAct[nLnk]);
pAct.push_back(dot);
}
}
示例6: isInside
bool ofxDraggableNode::isInside(ofPoint p) const {
ofPoint screenCenter = cam->worldToScreen(this->getGlobalPosition());
ofPoint screenCenterRadius = cam->worldToScreen(this->getGlobalPosition() + cam->getUpDir() * radius);
float r = screenCenter.distance(screenCenterRadius); //radius on screen
return p.distance(screenCenter) < r;
}