本文整理汇总了C++中ofPoint类的典型用法代码示例。如果您正苦于以下问题:C++ ofPoint类的具体用法?C++ ofPoint怎么用?C++ ofPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createWalkVect
WalkVect ofApp::createWalkVect(ofPoint velocity, ofPoint vector, IsLine line) {
ofPoint dir = vector.normalize();
if(velocity.y < 0) dir *= -1;
WalkVect vect;
vect.dir = dir;
vect.spd = velocity.length();
vect.line = line;
return vect;
}
示例3: ofPoint
void ofApp::update(){
mouse = ofPoint(mouseX, mouseY);
mouse -= center;
m = mouse.length();
cout << m << " is the magnitude of m" <<endl;
//unit vectors
mouse.normalize();
mouse*=50;
}
示例4: 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);
}
}
}
示例5: getClosestPointUtil
//----------------------------------------------------------
// http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/
static ofPoint getClosestPointUtil(const ofPoint& p1, const ofPoint& p2, const ofPoint& p3, float* normalizedPosition) {
// if p1 is coincident with p2, there is no line
if(p1 == p2) {
if(normalizedPosition != NULL) {
*normalizedPosition = 0;
}
return p1;
}
float u = (p3.x - p1.x) * (p2.x - p1.x);
u += (p3.y - p1.y) * (p2.y - p1.y);
// perfect place for fast inverse sqrt...
float len = (p2 - p1).length();
u /= (len * len);
// clamp u
if(u > 1) {
u = 1;
} else if(u < 0) {
u = 0;
}
if(normalizedPosition != NULL) {
*normalizedPosition = u;
}
return p1.getInterpolated(p2, u);
}
示例6: 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));
}
}
示例7: getNormalPoint
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;
}
示例8: getColor
ofFloatColor getColor(ofPoint point)
{
float max = point.lengthSquared();
double r,g,b;
double color = (max / (maxDistance/13));
if (color < 1)
{
r = (1 - color) ;
g = color;
b = 0;
}
else if (color < 2)
{
color--;
r = 0;
g = 1 - color;
b = color;
}
else
{
r = 0;
g = 0;
b = 1;
}
return ofFloatColor(r,g,b);
}
示例9: drawPointOnLine
//--------------------------------------------------------------
void testApp:: drawPointOnLine(ofPoint p1, ofPoint p2, float t){
t = ofClamp(t, 0, 1);
ofPoint circleCenter = p1.getInterpolated(p2, t);
ofCircle(circleCenter, 5);
ofLine(p1, p2);
ofCircle(p1, 3);
ofCircle(p2, 3);
}
示例10: vertexInterp
void ofxMarchingCubes::vertexInterp(float threshold,const ofPoint& p1,const ofPoint& p2, float valp1, float valp2, ofPoint& theVertice){
float mu;
if (ABS(threshold-valp1) < 0.00001){
theVertice.set(p1.x, p1.y, p1.z);
return;
}
if (ABS(threshold-valp2) < 0.00001){
theVertice.set(p2.x, p2.y, p2.z);
return;
}
if (ABS(valp1-valp2) < 0.00001){
theVertice.set(p1.x, p1.x, p1.z);
return;
}
mu = (threshold - valp1) / (valp2 - valp1);
theVertice.x = p1.x + mu * (p2.x - p1.x);
theVertice.y = p1.y + mu * (p2.y - p1.y);
theVertice.z = p1.z + mu * (p2.z - p1.z);
}
示例11: findClosestIntersectionLineAndPoly
bool findClosestIntersectionLineAndPoly( ofPoint a, ofPoint b, vector<ofPoint> pts, ofPoint & closestPoint, int & sideId )
{
if(pts.size() <= 0 ) return false;
vector<float> dist;
vector<ofPoint> ipts;
vector<int> ids;
//if( pts[0].x != pts[ pts.size()-1].x && pts[0].y != pts[ pts.size()-1].y)
pts.push_back(pts[0]);
for( int i = 1; i < pts.size(); i++)
{
ofPoint iPt;
if ( intersectionTwoLines( pts[i-1], pts[i], a, b, &iPt ) )
{
dist.push_back( ( (a.x-iPt.x) *(a.x-iPt.x) + (a.y-iPt.y)*(a.y-iPt.y) ) );
ipts.push_back( iPt );
ids.push_back(i-1);
}
}
closestPoint.set(0,0);
if( ipts.size() <= 0 ) return false;
ofPoint p = ofPoint(0,0);
float cdist = 0;
for( int i = 0; i < dist.size(); i++)
{
if( i == 0 || dist[i] < cdist )
{
cdist = dist[i];
p.set( ipts[i].x,ipts[i].y );
sideId = ids[i];
}
}
closestPoint.set(p.x,p.y);
return true;
}
示例12: update
void update(){
Hands= ofPoint(x,y); //location of the hands in the air ( ir sensors)
dir= ofPoint(Hands - location);
dir.normalize();
dir *=0.01;
accel= dir;
velocity += accel; //speed
location += velocity; // where is + the movement speed
velocity.limit(maxspeed); //verctor doesnt get bigger then 3
//collision target
if(ofDist(Target.x,Target.y, location.x, location.y)<rectSize){
points ++;
Target=ofPoint(ofRandom(20,ofGetWidth()-20), ofRandom(20,ofGetHeight()-20));
hitsound.play();
}
}
示例13: ofPoint
//Update vars based on Acceleration = Force/Mass
void Particle::refresh() {
accel.x = force.x/mass;
accel.y = force.y/mass;
vel+= accel;
pos += vel;
//Restrict pos to window bounds
//Find glancing direction by adding 180 - 2theta degrees
//Left/Right border collision
if(pos.x <= 0 || pos.x >= ofGetWindowWidth()) {
float theta = vel.angle(ofPoint(0, 1));
vel.rotate(180, ofPoint(0,1));
}
//Top/Bottom border collision
if(pos.y <= 0 || pos.y >= ofGetWindowHeight()) {
float theta = vel.angle(ofPoint(1, 0));
vel.rotate(180, ofPoint(1,0));
}
accel = ofPoint(0,0);
}
示例14: drawVector
void ofApp::drawVector(ofPoint v, ofPoint loc, float scayl){
ofPushMatrix();
float arrowsize = 4;
// Translate to location to render vector
ofTranslate(loc);
ofColor(255);
// Call vector heading function to get direction (note that pointing up is a heading of 0) and rotate
float angle = (float)atan2(-v.y, v.x);
float theta = -1.0*angle;
float heading2D = ofRadToDeg(theta);
ofRotateZ(heading2D);
// Calculate length of vector & scale it to be bigger or smaller if necessary
float len = v.length()*scayl;
// Draw three lines to make an arrow (draw pointing up since we've rotate to the proper direction)
ofDrawLine(0,0,len,0);
ofDrawLine(len,0,len-arrowsize,+arrowsize/2);
ofDrawLine(len,0,len-arrowsize,-arrowsize/2);
ofPopMatrix();
}
示例15: 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);
}
}