Esempio n. 1
0
void C2M::buildRings(CurvePtr sp){
	if (!sp)
		return; 
	cout<<"rwfer:"<<sp->size()<<endl;
	ac = new ArrCurve(sp->toArr(), sp->size(), true);
	RingPtr pre = 0;
	for(int i=0; i<ac->size(); i++){

		Vec3 o = ac->getP(i);
		Vec3 no = (o - Eye::get()->P).normalize();
		Vec3 tan = ac->getT(i);
		Vec3 up = (no%tan).normalize();

		double z = (o - Eye::get()->P).norm();
		Vec3 pmid = Eye::get()->P + no*( PZ / (no*Eye::get()->N) );

		ac->setP(i, pmid);
		double t0 = getHit(pmid, up);
		double t1 = getHit(pmid, -up);
		//cout<<"..........................................."<<endl;
		if (t0<0 || t1<0)
			continue;

		Vec3 p0 = pmid + up*t0;
		Vec3 p1 = pmid - up*t1;

		o = (p0+p1)*0.5;
		z = (o - Eye::get()->P).norm();
		//o = Eye::get()->P + ((p0+p1)*0.5 - Eye::get()->P ).normalize()*z;
		no = (o - Eye::get()->P).normalize();

		Vec3 n0 = (p0 - Eye::get()->P).normalize();
		Vec3 n1 = (p1 - Eye::get()->P).normalize();
		double a0 = z * (n0*no);
		double a1 = z * (n1*no);
		double a = (a0+a1)*0.5;

		//recompute center to be exactly in the middle of p0 and p1 
		RingPtr rng  = new Ring(o, Eye::get()->P + a*n0, Eye::get()->P + a*n1);
		//rng->reorient(tan);
		if (pre)
			rng->setPrevNext(pre,0);
		else
			_rings.push_back(rng);
		pre = rng;
	}
}
Esempio n. 2
0
void BetaGrid::getWeightedFlatDescription(std::vector<double>& description, std::vector<double>& weight) const {
    description.clear();
    double sum = 0.;
    for(unsigned int i = 0; i < m_histogram.size(); i++) {
        for(unsigned int j = 0; j < m_histogram[i].size(); j++) {
            double mean = (getHit()[i][j]+1)/(getHit()[i][j] + getMiss()[i][j]+2);
            double variance = (getHit()[i][j]+1) * (getMiss()[i][j]+1)/
                              ( (getHit()[i][j] + getMiss()[i][j]+2) * (getHit()[i][j] + getMiss()[i][j]+2) *
                                (getHit()[i][j] + getMiss()[i][j] + 3));
            description.push_back(mean);
            weight.push_back(1./variance);
// 	    description.push_back(m_hit[i][j]);
            sum += description.back();
        }
    }
    /*    if(sum < 10e-6){
    	for(std::vector<double>::iterator it = description.begin(); it != description.end(); it++){
    	    *it = 10e-10;
    	}
        } else {
          	for(std::vector<double>::iterator it = description.begin(); it != description.end(); it++){
    	    *it /= sum;
    	}
        }*/
}
Esempio n. 3
0
void TouchManager::inputBegin(const int fingerId, const ci::Vec2f& touchPos){
	mDiscardTouchMap[fingerId] = false;

	ci::Vec3f globalPoint = ci::Vec3f(touchPos, 0.0f);

	TouchInfo touchInfo;
	touchInfo.mCurrentGlobalPoint = globalPoint;
	touchInfo.mFingerId = fingerId;
	touchInfo.mStartPoint = mTouchStartPoint[touchInfo.mFingerId] = touchInfo.mCurrentGlobalPoint;
	mTouchPreviousPoint[fingerId] = globalPoint;
	touchInfo.mDeltaPoint = ci::Vec3f::zero();

	// Catch a case where two "touch added" calls get processed for the same fingerID
	// WITHOUT a released in the middle. This would case the previous sprite to be left with an erroneous finger
	// So we fake remove it before adding the new one
	if(mFingerDispatcher[touchInfo.mFingerId]) {
		DS_LOG_WARNING("Double touch added on the same finger Id: " << touchInfo.mFingerId << ", removing previous sprite tracking.");
		touchInfo.mPickedSprite = mFingerDispatcher[touchInfo.mFingerId];
		touchInfo.mPhase = TouchInfo::Removed; // fake removed
		touchInfo.mPassedTouch = true; // passed touch flag indicates that this info shouldn't be used to trigger buttons, etc. implementation up to each sprite
		mFingerDispatcher[touchInfo.mFingerId]->processTouchInfo(touchInfo);
		mFingerDispatcher[touchInfo.mFingerId] = nullptr;

	}

	touchInfo.mPhase = TouchInfo::Added;
	touchInfo.mPassedTouch = false;

	if(mCapture) mCapture->touchBegin(touchInfo);

	Sprite *currentSprite = getHit(touchInfo.mCurrentGlobalPoint);
	touchInfo.mPickedSprite = currentSprite;
	mRotationTranslator.down(touchInfo);

	if(mSmoothEnabled){
		mTouchSmoothPoints[fingerId].clear();
		mTouchSmoothPoints[fingerId].push_back(touchInfo.mCurrentGlobalPoint);
	}

	if(currentSprite) {
		mFingerDispatcher[touchInfo.mFingerId] = currentSprite;
		currentSprite->processTouchInfo(touchInfo);
	}

	if(mEngine.getTouchInfoPipeCallback()){
		mEngine.getTouchInfoPipeCallback()(touchInfo);
	}
}
Esempio n. 4
0
void TouchManager::touchesBegin(const TouchEvent &event) {
	for (std::vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt) {

		// This system uses a mouse click for the first touch, which allows for use of the mouse and touches simultaneously
		// It's possible we'll run into a scenario where we need to reverse this, which we can just add a bool flag to the settings to use all touches and ignore all mouses.
		if (TouchMode::hasSystem(mTouchMode) && ci::System::hasMultiTouch() && TouchMode::hasMouse(mTouchMode)) {
			mIgnoreFirstTouchId = touchIt->getId();
			return;
		}

		ci::Vec2f touchPos = touchIt->getPos();
		if(mOverrideTranslation){
			overrideTouchTranslation(touchPos);
		}

		int fingerId = touchIt->getId() + MOUSE_RESERVED_IDS;
  
		if(shouldDiscardTouch(touchPos)){
			mDiscardTouchMap[fingerId] = true;
			continue;
		}

		mDiscardTouchMap[fingerId] = false;

		TouchInfo touchInfo;
		touchInfo.mCurrentGlobalPoint = Vec3f(touchPos, 0.0f);
		touchInfo.mFingerId = fingerId;
		touchInfo.mStartPoint = mTouchStartPoint[touchInfo.mFingerId] = touchInfo.mCurrentGlobalPoint;
		mTouchPreviousPoint[touchInfo.mFingerId] = touchInfo.mCurrentGlobalPoint;
		touchInfo.mDeltaPoint = touchInfo.mCurrentGlobalPoint - mTouchPreviousPoint[touchInfo.mFingerId];
		touchInfo.mPhase = TouchInfo::Added;
		touchInfo.mPassedTouch = false;

		if (mCapture) mCapture->touchBegin(touchInfo);

		Sprite *currentSprite = getHit(touchInfo.mCurrentGlobalPoint);
		touchInfo.mPickedSprite = currentSprite;
		mRotationTranslator.down(touchInfo);

		if ( currentSprite ) {
			mFingerDispatcher[touchInfo.mFingerId] = currentSprite;
			currentSprite->processTouchInfo(touchInfo);
		}
	}
}
Esempio n. 5
0
void TouchManager::mouseTouchBegin(const MouseEvent &event, int id ){

	TouchInfo touchInfo;
	touchInfo.mCurrentGlobalPoint = Vec3f(translateMousePoint(event.getPos()), 0.0f);
	touchInfo.mFingerId = id;
	touchInfo.mStartPoint = mTouchStartPoint[touchInfo.mFingerId] = touchInfo.mCurrentGlobalPoint;
	mTouchPreviousPoint[touchInfo.mFingerId] = touchInfo.mCurrentGlobalPoint;
	touchInfo.mDeltaPoint = touchInfo.mCurrentGlobalPoint - mTouchPreviousPoint[touchInfo.mFingerId];
	touchInfo.mPhase = TouchInfo::Added;
	touchInfo.mPassedTouch = false;

	if (mCapture) mCapture->touchBegin(touchInfo);

	Sprite *currentSprite = getHit(touchInfo.mCurrentGlobalPoint);
	touchInfo.mPickedSprite = currentSprite;
	mRotationTranslator.down(touchInfo);

	if ( currentSprite ) {
		mFingerDispatcher[touchInfo.mFingerId] = currentSprite;
		currentSprite->processTouchInfo(touchInfo);
	}
}