Esempio n. 1
0
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;

}
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();
}
Esempio n. 3
0
	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);
	}
	float getRadius() {
		return position.length();
	}