本文整理汇总了C++中ofPoint类的典型用法代码示例。如果您正苦于以下问题:C++ ofPoint类的具体用法?C++ ofPoint怎么用?C++ ofPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:bestpaul1985,项目名称:Thesis2013,代码行数:35,代码来源:ttRopeBasic.cpp
示例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;
}
开发者ID:mattvisco,项目名称:SFPC_2016,代码行数:9,代码来源:ofApp.cpp
示例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;
}
开发者ID:bajor,项目名称:Interactive_Development_in_Open_Frameworks,代码行数:12,代码来源:ofApp.cpp
示例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);
}
}
}
开发者ID:jbobrow,项目名称:MonTagger,代码行数:15,代码来源:ofApp.cpp
示例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);
}
开发者ID:AinurBegalinova,项目名称:TreasureHuntingRobot,代码行数:28,代码来源:ofPolyline.cpp
示例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));
}
}
开发者ID:Doodle3D,项目名称:Doodle3D,代码行数:27,代码来源:main.cpp
示例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;
}
开发者ID:patriciogonzalezvivo,项目名称:megaphone,代码行数:35,代码来源:SuperGlyph.cpp
示例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);
}
开发者ID:Bbenchaya,项目名称:PointCloud_Viewer,代码行数:28,代码来源:targetver.cpp
示例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);
}
开发者ID:Sandrofredericoz,项目名称:dtplayfulsystems,代码行数:10,代码来源:testApp.cpp
示例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);
}
开发者ID:atduskgreg,项目名称:ofxMarchingCubes,代码行数:19,代码来源:ofxMarchingCubes.cpp
示例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;
}
开发者ID:alocfc,项目名称:Graffiti-Analysis-3.0,代码行数:43,代码来源:polyUtils.cpp
示例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();
}
}
开发者ID:ra-amon,项目名称:myApps,代码行数:21,代码来源:ofApp.cpp
示例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);
}
开发者ID:wqawasmi,项目名称:ofGravity,代码行数:25,代码来源:ofApp.cpp
示例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();
}
开发者ID:anteaterho,项目名称:natureOFcode,代码行数:21,代码来源:ofApp.cpp
示例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);
}
}
开发者ID:patriciogonzalezvivo,项目名称:mesaDelTiempo,代码行数:22,代码来源:Communitas.cpp
示例16: 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;
}
开发者ID:Kj1,项目名称:OF_COURCE_ICON,代码行数:6,代码来源:ofxDraggableNode.cpp
示例17: getDistance
float ofxVoronoi::getDistance(ofPoint p1, ofPoint p2){
return p1.squareDistance(p2);
}
开发者ID:madc,项目名称:ofxVoronoi,代码行数:3,代码来源:ofxVoronoi.cpp
示例18: glClear
void testApp::draw() {
// clear depth buffer (but not color buffer)
glClear(GL_DEPTH_BUFFER_BIT);
// enable blending
glEnable(GL_BLEND);
// choose semi-transparent black color
myObj.setColor(0, 0, 0, 0.05f);
// draw a black semi-transparent rectangle across whole screen to fade it out a bit
myObj.drawRect(0, 0, ofGetWidth(), ofGetHeight());
// disable blending
glDisable(GL_BLEND);
// get current time (could use ofGetElapsedTimef() but I DONT want it to be fps independant
// cos when I'm saving frames and it's running slow I want it to behave the same
float curTime = ofGetFrameNum() * 1.0f/60.0f;
// choose start rotation based on curTime
float theta = sin(curTime * 0.17f) * TWO_PI;
// set start position offset from center of screen
float startOffset = -50.0f * sin(curTime * 0.09f);
pos.set(ofGetWidth()/2 + cos(theta) * startOffset, ofGetHeight()/2 + sin(theta) * startOffset, 0);
// begin a triangle strip
myObj.begin(GL_TRIANGLE_STRIP);
for(int i=0; i<5000; i++) {
// calculate and set colors
// RGB components modulate sinusoidally, frequency increases with iteration count
myObj.setColor(sin(curTime * 0.8f + i * 0.0011f) * 0.5f + 0.5f, sin(curTime * 0.7f + i * 0.0013f) * 0.5f + 0.5f, sin(curTime * 0.3f + i * 0.0017f) * 0.5f + 0.5f);
// do some maths to calculate vertex positions
// modulate theta (offset rotation) sinusoidally, frequency increases with iteration count
// use two modulations with different frequencies to create complex harmonic motion
theta += sin(curTime * 0.1f + i * 0.00062f) * 2.0f * DEG_TO_RAD * i * 0.0004 + sin(curTime*0.2f + i * 0.0009f) * 3.0f * DEG_TO_RAD;
float cos_t = cos(theta);
float sin_t = sin(theta);
// x, y position cumulatively rotates
// z position modulates sinusoidally, frequency increases with iteration count
pos += ofPoint(cos_t, sin_t, sin(curTime * 0.5f + i*0.002f) * 0.5);
// send vertex data to myObj
myObj.addVertex(pos.x, pos.y, pos.z);
// do some math to calculate another vertex position
// perpendicular to rotation
// thickness modulates sinusoidally, frequency increases with iteration count
// also modulation frequency sinusoidally
ofPoint pos2 = pos + ofPoint(sin_t, -cos_t) * ofMap(sin(curTime * 0.4f * ( 1.0f + i * 0.001f) + i * 0.06f + sin(i*0.001f) * 0.2f), -1, 1, 5, 10 + i * 0.01f);
// place second vertex (can also pass pointer (array) to coordinates)
myObj.addVertex2v(pos2.v);
}
// end vertices and draw to screen
myObj.end();
}
开发者ID:6301158,项目名称:ofx-dev,代码行数:62,代码来源:testApp.cpp
示例19: ofSetupScreen
//--------------------------------------------------------------
void camApp::draw(){
//hitTest();
ofSetupScreen();
float width = ofGetWidth();
float height = ofGetHeight();
//TODO: check why the background was fading weird on rise background - OpenGL related bug?
ofEnableAlphaBlending();
ofSetColor(255, 255, 255, 255);
background.draw(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth(), ofGetHeight() );
ofSetColor(255, 255, 255, ofMap(riseFallPct, 0.49, 0.0, 0, 255, true));
background2.draw(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth(), ofGetHeight());
world.setScale(ofGetWidth(), ofGetHeight(), ofGetWidth());
world.setOrigin(ofPoint(ofGetWidth()/2, ofGetHeight()/2, 0.0));
world.begin();
world.ourCameraSetup(width/2, height/2, 0.0, width, height, fov );
//world.drawDebugGrid();
glDisable(GL_DEPTH_TEST);
sceneGraph.updateCameraPos(world.camPos + ofPoint(0, 0, world.camDist));
sceneGraph.sortZ();
ofRectangle clipRect;
clipRect.width = 2.0 * ofGetWidth();
clipRect.height = 2.2 * ofGetHeight(); // lets give us some extra room!
clipRect.x = world.camPos.x - clipRect.width/2;
clipRect.y = world.camPos.y - clipRect.height/2;
//TODO: MAKE PLANT CLIPPING BETTER
sceneGraph.renderWithClipping(clipRect, -180+world.camPos.z, 100 + world.camPos.z, world.camDist, fov );
hand.updateCamToScreenCoords();
GLdouble model_view[16];
glGetDoublev(GL_MODELVIEW_MATRIX, model_view);
GLdouble projection[16];
glGetDoublev(GL_PROJECTION_MATRIX, projection);
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
GLdouble X, Y, Z = 0;
gluProject(myPerson.pos.x, myPerson.pos.y, myPerson.pos.z, model_view, projection, viewport, &X, &Y, &Z);
personScreenPos.set(X, ofGetHeight()-Y, Z);
world.end();
ofSetupScreen();
//this node draws in screen space.
hand.draw();
if( percentOver > 0.0 ){
ofSetColor(255, 255, 255, 255*percentOver*1.2);
if( endCreatedInRise ){
backgroundEnd.draw(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth(), ofGetHeight());
}else{
backgroundEnd2.draw(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth(), ofGetHeight());
}
world.begin();
world.ourCameraSetup(width/2, height/2, 0.0, width, height, fov );
endGraphic.draw();
myPerson.draw();
world.end();
ofSetupScreen();
}
if( howTo.state != NODE_INACTIVE ){
howTo.draw();
myPerson.drawAtScreenPos(personScreenPos.x, personScreenPos.y, 0);
}
ofSetColor(10, 50, 150);
ofDrawBitmapString(hitsString, 10, 50);
ofEnableAlphaBlending();
}
开发者ID:emmanuelgeoffray,项目名称:RideAndFall-037,代码行数:91,代码来源:camApp.cpp
示例20: setup
//--------------------------------------------------------------
void ofApp::setup(){
ofSetWindowShape(1024,1024);
ofSetBackgroundAuto(true);
//ofBackground(0,0,0); // background
ofBackground(128,128,128); // background
imageCrystal.loadImage("crystal.jpg"); //load initial image
point.set(10,10);
ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
}
开发者ID:Kerstinhovland,项目名称:Tech3701week3Examples,代码行数:13,代码来源:ofApp.cpp
注:本文中的ofPoint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论