• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ofVec2f类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ofVec2f的典型用法代码示例。如果您正苦于以下问题:C++ ofVec2f类的具体用法?C++ ofVec2f怎么用?C++ ofVec2f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ofVec2f类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: spawnHandle

shared_ptr<handle> handle::press(ofVec2f t_vec, int ha) {

    //mouse coordinates already translated in testApp
    shared_ptr<handle> ptr;

    m_isActive = true;

    if(!m_parent && m_children.size() == 0 || ha == HA_VEC_SPAWN) {

        ptr = spawnHandle();
        m_inputMapper = shared_ptr<inputMapper>(new vecInput()); //need to think how parameters for this are set
        shared_ptr<vecInput> t_vi(static_pointer_cast <vecInput>(m_inputMapper));

        if(t_vec.length() > 10){
            t_vi->setDirGlobal(t_vec.getNormalized());
        }else{
            t_vi->setDirGlobal(ofVec2f(0,1));
        }

    }

    if(m_inputMapper) {
        reset();
        m_inputMapper->start();
    }


    return ptr;

}
开发者ID:kimon-satan,项目名称:soundChain,代码行数:30,代码来源:handle.cpp


示例2: getTriangleRadius

 //-------------------------------------------------------------------
 static float getTriangleRadius(ofVec2f v1, ofVec2f v2, ofVec2f v3) {
     
     float a = v1.distance(v2);
     float b = v2.distance(v3);
     float c = v3.distance(v1);
     
     float k = 0.5 * (a+b+c);
     
     float r = sqrt( k * ((k-a)*(k-b)*(k-c)) ) / k;
     return r;
 }
开发者ID:imclab,项目名称:muncyt,代码行数:12,代码来源:utilsGeom.cpp


示例3: getTriangleCenter

 //-------------------------------------------------------------------
 static ofVec2f getTriangleCenter(ofVec2f v1, ofVec2f v2, ofVec2f v3) {
     
     float a = v2.distance(v3);
     float b = v1.distance(v3);
     float c = v1.distance(v2);
     float d = a+b+c;
     
     float ix = ((a * v1.x) + (b * v2.x) + (c * v3.x)) / d;
     float iy = ((a * v1.y) + (b * v2.y) + (c * v3.y)) / d;
     
     return ofVec2f(ix, iy);
 }
开发者ID:imclab,项目名称:muncyt,代码行数:13,代码来源:utilsGeom.cpp


示例4: OpenFrameworksVector

void View::DrawGravityAt(ofPoint position, const Model &model) const {
  const ofVec2f gravity = OpenFrameworksVector(model.GravityAt(Box2dVector(position)));
  ofPushStyle();
  ofPushMatrix();
  ofTranslate(position.x, position.y);
  ofScale(0.5, 0.5);
  ofSetColor(ofColor::slateGrey, 64.0);
  const ofVec2f arrowhead = gravity / 9.81;
  ofTriangle(arrowhead, kBallRadius * arrowhead.perpendiculared(),
             -kBallRadius * arrowhead.perpendiculared());
  ofPopMatrix();
  ofPopStyle();
}
开发者ID:robertsdionne,项目名称:witchball,代码行数:13,代码来源:view.cpp


示例5: setDirection

void FlowField::setDirection(ofVec2f _dir) {
    _dir.normalize();
    for( int y=0; y<flowList.size(); y++){
        for( int x=0; x<flowList[y].size(); x++){
            flowList[y][x] += _dir;
        }
    }
}
开发者ID:ovicin,项目名称:giang063_sims2014,代码行数:8,代码来源:FlowField.cpp


示例6: GetControlPointAtPosition

int BSpline::GetControlPointAtPosition(ofVec2f position)
{
	for (int i = 0; i < controlPoints.size(); ++i) {
		if (position.distance(controlPoints[i]) < 10)
			return i;
	}
	return -1;
}
开发者ID:FredMarquer,项目名称:Math_Bezier,代码行数:8,代码来源:BSpline.cpp


示例7: checkAngle

bool TriangleBrush::checkAngle(ofVec2f p1, ofVec2f p2, ofVec2f p3){
            float dist1 = p1.distance(p2);
            float dist2 = p1.distance(p3);
            if (dist2 < dist1) {
                return true;
            }else{
                return false;
            }
}
开发者ID:GordeyChernyy,项目名称:DrawingTool,代码行数:9,代码来源:TriangleBrush.cpp


示例8: getNearestVertex

float getNearestVertex(const ofMesh& mesh, const ofVec2f& target, int& vertexIndex) {
	float bestDistance = 0;
	for(int i = 0; i < mesh.getNumVertices(); i++) {
		float distance = target.distance(mesh.getVertex(i));
		if(distance < bestDistance || i == 0) {
			bestDistance = distance;
			vertexIndex = i;
		}
	}
	return bestDistance;
}
开发者ID:elazrus,项目名称:ofxPuppet,代码行数:11,代码来源:ofxPuppetInteractive.cpp


示例9: closestPointOnRay

ofVec2f closestPointOnRay(const ofVec2f& p1, const ofVec2f& p2, const ofVec2f& p3) {
	if(p1 == p2) {
		return p1;
	}
	
	float u = (p3.x - p1.x) * (p2.x - p1.x);
	u += (p3.y - p1.y) * (p2.y - p1.y);
	float len = (p2 - p1).length();
	u /= (len * len);
	
	return p1.getInterpolated(p2, u);
}
开发者ID:DanielTillett,项目名称:OpenFit,代码行数:12,代码来源:Geometry.cpp


示例10: interaccion_point

void menu::interaccion_point(ofVec2f ptF, bool isNeg) {
	float minDis = ofGetHeight()/3.0;// (isNeg)? 400 : 200;
	
	float minDis2 = minDis*minDis;
	
	float ff = 1.0;

	float fFuerza = 45.0;
	if(ptF.distance(centro)<distConf) {
//	if(ptF.squareDistance(centro)<distConf) {
		if(isNeg) {
			// Atrae circulos y repele boxes
			for(int i=0; i<circles.size(); i++) {
//				float dis = ptF.distance(circles[i].get()->getPosition());
				float dis2 = ptF.squareDistance(circles[i].get()->getPosition());
//				if(dis < minDis) 
//				if(dis2 < minDis2) 
//					circles[i].get()->addRepulsionForce(ptF, ff*1.4f*fFuerza/dis2);//3, 9);
//				else 
//					circles[i].get()->addAttractionPoint(ptF, ff*2.2*fFuerza/dis2);//4.0);
				
				circles[i].get()->addAttractionPoint(ptF, ff*2.2*fFuerza/dis2);//4.0);
				
			}
			for(int i=0; i<boxes.size(); i++) {
				float dis = ptF.distance(boxes[i].get()->getPosition());
				float dis2 = dis*dis;//ptF.squareDistance(boxes[i].get()->getPosition());
//				if(dis < minDis) 
//				if(dis2 < minDis2) 
//					boxes[i].get()->addAttractionPoint(ptF, ff*1.2*fFuerza/dis2);
//				else 
//					boxes[i].get()->addRepulsionForce(ptF, ff*0.8*fFuerza/dis2);//4.0);
				boxes[i].get()->addRepulsionForce(ptF, ff*0.9*fFuerza/dis2);//4.0);
			}
		}
		else {
			// Mouse Pressed
			// Atrae boxes y repele circulos
			for(int i=0; i<circles.size(); i++) {
//				float dis = ptF.distance(circles[i].get()->getPosition());
				float dis2 = ptF.squareDistance(circles[i].get()->getPosition());
//				if(dis < minDis) 
//				if(dis2 < minDis2) 
//					circles[i].get()->addAttractionPoint(ptF, ff*1.2*fFuerza/dis2);//3, 9);
//				else 
					circles[i].get()->addRepulsionForce(ptF, ff*0.8*fFuerza/dis2);//4.0);
			}
			for(int i=0; i<boxes.size(); i++) {
				float dis = ptF.distance(boxes[i].get()->getPosition());
				float dis2 = ptF.squareDistance(boxes[i].get()->getPosition());
//				if(dis < minDis) 
				if(dis2 < minDis2) 
//					boxes[i].get()->addRepulsionForce(ptF, ff*1.4*fFuerza/dis);
//				else 
					boxes[i].get()->addAttractionPoint(ptF, ff*2.2*fFuerza/dis2);//4.0);
			}
		}
	}

}
开发者ID:serman,项目名称:muncyt,代码行数:60,代码来源:menu_interaccion.cpp


示例11: getTriangleFromSegmentSize

bool getTriangleFromSegmentSize(double _szA, double _szB, double _szC, double x0, double y0, double _angle, double _scale, ofVec2f & _ptA, ofVec2f & _ptB, ofVec2f & _ptC) {

    double r0 = _szB * _scale;
    double x1 = 0 + _szA * _scale;
    double y1 = 0;
    double r1 = _szC * _scale;

    vector<ofVec2f> _points;

    circlesIntersection(0, 0, r0, x1, y1, r1, _points);

    if(_points.size() == 0) return false; // dont intersect --- sides dont make a triangle

    _ptA.set(0, 0);
    _ptB.set(x1, y1);
    _ptC.set(_points[1].x, _points[1].y);

    _ptC.x = _ptB.x + (_ptA.x - _ptC.x);
    _ptC.y = _ptB.y + (_ptA.y - _ptC.y);

    double _sin = sin(ofDegToRad(_angle));
    double _cos = cos(ofDegToRad(_angle));

    ofVec2f _pivot = (_ptA + _ptB + _ptC) / 3.0;

    _ptA -= _pivot;
    _ptB -= _pivot;
    _ptC -= _pivot;

    _ptA = rotatePoint(_ptA.x, _ptA.y, 0, 0, 0, 0, _sin, _cos);
    _ptB = rotatePoint(_ptB.x, _ptB.y, 0, 0, 0, 0, _sin, _cos);
    _ptC = rotatePoint(_ptC.x, _ptC.y, 0, 0, 0, 0, _sin, _cos);

    _ptA += ofVec2f(x0,y0);
    _ptB += ofVec2f(x0,y0);
    _ptC += ofVec2f(x0,y0);

    return true;
}
开发者ID:phdcosta,项目名称:phdGui,代码行数:39,代码来源:phdUtils.cpp


示例12: ofGetWidth

vector<ofVec2f> PyramidBrush::sortClosest(ofVec2f p, vector<ofVec2f> coords){
    vector<ofVec2f> pos;
    float maxDist = ofGetWidth();
    int closestIndex = 0;
    for (int i = 0; i < coords.size(); i++) {
        float dist = p.distance(coords[i]);
        if (dist < maxDist){
            maxDist = dist;
            pos.push_back(coords[i]);
        }
    }
    return pos;
}
开发者ID:GordeyChernyy,项目名称:DrawingTool,代码行数:13,代码来源:PyramidBrush.cpp


示例13: drawArrow

void KinectProjector::drawArrow(ofVec2f projectedPoint, ofVec2f v1)
{
    float angle = ofRadToDeg(atan2(v1.y,v1.x));
    float length = v1.length();
    ofFill();
    ofPushMatrix();
    ofTranslate(projectedPoint);
    ofRotate(angle);
    ofSetColor(255,0,0,255);
    ofDrawLine(0, 0, length, 0);
    ofDrawLine(length, 0, length-7, 5);
    ofDrawLine(length, 0, length-7, -5);
    ofPopMatrix();
}
开发者ID:Harrisandwich,项目名称:Magic-Sand,代码行数:14,代码来源:KinectProjector.cpp


示例14: np

void handle::pivot(float f, ofVec2f p, ofVec2f t, string jType, string actor){

    ofVec2f np(m_posC);

    if(jType == "weld"){

        np = m_posC.getRotated(f, p, ofVec3f(0,0,1));
        t.set(np - m_posC);
        m_posC.set(np);
        m_rotC += f;

    }else if(jType == "pivot"){
        if(m_posC != p){
            m_posC += t;
        }
    }

    //recursive function call on children
    vector <handleJoint>::iterator it = m_children.begin();

    while(it != m_children.end()){
        if(it->m_handle->getIndex() == actor){++it; continue;} //actor is to prevent double calls
        if(it->m_type == "free"){++it; continue;}
        if(jType == "weld" &&  it->m_type == "weld"){
            it->m_handle->pivot(f, p, t, "weld", m_index);
        }else if(jType == "pivot" || it->m_type == "pivot"){
            if(m_posC != p)it->m_handle->pivot(f, p, t, "pivot", m_index);
        }
        ++it;
    }

    //pivot the parent
    if(m_parent){
        if(actor != m_parent->getIndex()){

            handleJoint hj = m_parent->getChildJoint(m_index);

            if(jType == "weld" &&  hj.m_type == "weld"){
                m_parent->pivot(f, p, t, "weld", m_index);
            }else if(jType == "pivot" || hj.m_type == "pivot"){
                if(m_posC != p)m_parent->pivot(f, p, t, "pivot", m_index);
            }

        }
    }

}
开发者ID:kimon-satan,项目名称:soundChain,代码行数:47,代码来源:handle.cpp


示例15: _cameraImage

ofVec2f Simple3DTracker::_predictNextPosition(ofVec2f currentPosition, float* minCost)
{
    int bestx = currentPosition.x, besty = currentPosition.y;
    float bestcost = 9999999, cost, distance;
    const float alpha = _weightedMatchingCoefficient;

    if(!_template || !_tmp || !_tmp2)
        return currentPosition;

    // template matching
    IplImage* haystack = _cameraImage();
    cvMatchTemplate(haystack, _template->getCvImage(), _tmp2, CV_TM_CCOEFF);
    cvNormalize(_tmp2, _tmp2, 1.0, 0.0, CV_MINMAX);

    // find the best match
    for(int y = 0; y < _tmp2->height; y++) {
        const float *src = (const float*)(_tmp2->imageData + y * _tmp2->widthStep);
        unsigned char *dst = (unsigned char*)(_tmp->getCvImage()->imageData + y * _tmp->getCvImage()->widthStep);
        for(int x = 0; x < _tmp2->width; x++) {
            dst[x] = (unsigned char)(src[x] * 255.0f);
            distance = currentPosition.distance(ofVec2f(x, y));
            if(distance <= _lookupRadius) {
                cost = (alpha * (1.0f - src[x])) + ((1.0f - alpha) * distance / _lookupRadius);
                if(cost <= bestcost) { // weighted matching
                    bestx = x;
                    besty = y;
                    bestcost = cost;
                }
            }
        }
    }
    _tmp->flagImageChanged();

    // get the resulting position...
    ofVec2f result(bestx + _template->width/2, besty + _template->height/2);

    // return the min cost?
    if(minCost)
        *minCost = bestcost;

    // update the template?
    if(result.distance(currentPosition) >= UPDATETPL_MINDIST)
        _setTemplate(result);

    // done!
    return result;
}
开发者ID:alemart,项目名称:mestrado,代码行数:47,代码来源:Simple3DTracker.cpp


示例16: closestPointOnLine

ofVec2f closestPointOnLine(const ofVec2f& p1, const ofVec2f& p2, const ofVec2f& p3) {
    if(p1 == p2) {
        return p1;
    }

    float u = (p3.x - p1.x) * (p2.x - p1.x);
    u += (p3.y - p1.y) * (p2.y - p1.y);
    float len = (p2 - p1).length();
    u /= (len * len);

    // clamp u
    if(u > 1) {
        u = 1;
    } else if(u < 0) {
        u = 0;
    }
    return p1.getInterpolated(p2, u);
}
开发者ID:rpietruc,项目名称:qmediamodeler,代码行数:18,代码来源:closestpoint.cpp


示例17: ofVec2f

	ofVec2f Camera::undistortCoordinate(const ofVec2f & xy) const {
		const int distortionLength = this->distortion.size();
		
		if (this->distortion.size() < 2) {
			return xy;
		}
		
		float r = xy.length();
		float rr = r*r;
		
		float rad_coeff = 1.0f + distortion[0] * rr + distortion[1] * rr * rr;
		if (distortionLength > 4) {
			rad_coeff += distortion[4] * rr * rr * rr;
		}
		
		float xn = xy.x * rad_coeff;
		float yn = xy.y * rad_coeff;
		
		xn += 2 * distortion[2] * xn * yn + distortion[3] * (rr + 2 * xn * xn);
		yn += distortion[2] * (rr + 2 * yn * yn) + 2 * distortion[3] * xn * yn;
		
		return ofVec2f(xn, yn);
	}
开发者ID:kylemcdonald,项目名称:ofxRay,代码行数:23,代码来源:Camera.cpp


示例18: ofColor

Confetti::Confetti(ofVec2f origin, ofVec2f velVector, float divergenceFactor, float tempStrengthVar, int tempId){
	
	particleId = tempId; 
	
	color = ofColor(ofRandom(200),ofRandom(200),ofRandom(200));
	//color = ofColor(255);
	gravity = ofVec3f(0,1,0);
	
	strengthVariation = tempStrengthVar;
	externalForce = ofVec2f(0,0);
	
	pos = ofVec3f(origin.x, origin.y, 0);
	
	accel = velVector;
	accel.z = ofRandom(-100,100);
	
	divergence = velVector.getRotated(ofRandom(-divergenceFactor,divergenceFactor));

	//vel = ofVec3f(velVector.x, velVector.y, velVector.x); // ASSIGNO X AL Z
	vel = accel;
	
	vel.x += divergence.x;
	vel.y += divergence.y;
	//vel.z += divergence.x;
	
	strength = (ofRandom(1 - strengthVariation,1));
	
	//strength = 1;
	vel *= strength;
	
	accel = 0;

	
	rotation = ofRandom(360);
	rotationStep = ofRandom(-10,10);

}
开发者ID:Anirbas,项目名称:proyectoConfetti,代码行数:37,代码来源:Confetti.cpp


示例19: select_point

bool select_point(ofVec2f f, ofVec2f t, float r)
{
	if ( f.distance(t) < r ) return true;
	else					 return false;
}
开发者ID:Geistyp,项目名称:SimpleMappingtools,代码行数:5,代码来源:testApp.cpp


示例20: isPointOverCenter

bool Sphere::isPointOverCenter(ofVec2f p, float radiusMultiply)
{
    return p.distance(center) < SphereTones::sphereRadius * radiusMultiply;
}
开发者ID:ErNancy,项目名称:SphereTones,代码行数:4,代码来源:Sphere.cpp



注:本文中的ofVec2f类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofVec3f类代码示例发布时间:2022-05-31
下一篇:
C++ ofTrueTypeFont类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap