예제 #1
0
//--------------------------------------------------------------
void testApp::draw(){
    centroid = center;
    cam.setPosition(ofVec3f(0, 0, -centroid.z));
    
    cam.lookAt(centroid, ofVec3f(0,1,0));
    cam.setFarClip(50000);
    
    cam.begin();
    
    ofPushMatrix();
    ofTranslate(camPosX, camPosY, camZoom);
    
    if(bTop){
        pivot(centroid, 100, 0, 0);
    }
    else{
        pivot(centroid, camRotX, camRotY, 0);
    }
    
    ofScale(-1.0, 1.0, 1.0);
    drawAxes(centroid, refPoint);
    
    ofPushStyle();
    
    //-------------------------
    for(int i = 0; i < K; i++)
        kinects[i].draw();
    
    
    if(bCalibrated && bTracking){
        for(int i = 0; i < N; i++)
            trackers[i].draw();
        
        for(int i = 0; i < N - 1; i++)
            for(int j = 1; j < N; j++){
                setLineColor(i + j);
                ofLine(trackers[i].lerpedPos, trackers[j].lerpedPos);
            }
        
        //-------------------------
        ofEnableAlphaBlending();
        ofSetColor(255, 0, 0, 50);
        ofFill();
        ofBeginShape();
        for(int i = 0; i < N; i++)
            ofVertex(trackers[i].lerpedPos);
        ofEndShape();
        ofDisableAlphaBlending();
        //-------------------------
    }
    
    ofPopStyle();
   

    ofPopMatrix();

    cam.end();
    
    gui.draw();    
}
예제 #2
0
파일: Wrkf1.cpp 프로젝트: cran/subselect
bool  Forward_DepthF_Search(vind frwind0,vind fvind,vind lvind,vind nvfrwd)  
{
	vind nv,minnv,maxnv,minnvfrd,maxnvfrd;
	vind t,frwind(frwind0);
	real maxstcrt(NOBND);
	subsetdata* prvdatapt;

	if (lvind-fvind > 10) {
		newtime = clock();
		if (newtime==clock_t(-1))  {
			msg("Eleaps error: time overflow\n");
			return false;
		}
		rtime -= static_cast<double>(newtime-ctime);
		if (rtime < 0.) return false;  // Exit if time limit was exceded
		ctime = newtime; 
	} 

//  Find maximal subset dimensionalities of current tree branches
	
	if ( (maxnvfrd=nvfrwd+lvind-fvind+1) > maxdim) maxnvfrd = maxdim;

//  Start pivoting variables 

	{ for (vind u=fvind;u<=lvind;u++)  {

		t = lvind-u; 

//		Set number of variables in the susbset where the current pivot will be performed
		nv = minnvfrd = nvfrwd+u-fvind+1;

		if (maxnvfrd >= mindim && minnvfrd <= maxdim)  {

//			Make a pivot	
			if (minnvfrd < mindim) pivot(SW,SRC,frwind,t,nv,u,t,mindim,maxnvfrd,false);
			else if (minnvfrd < maxdim) pivot(SW,SRC,frwind,t,nv,u,t,minnvfrd,maxnvfrd,false);
				 else pivot(SW,SRC,frwind,0,nv,u,t,minnvfrd,maxnvfrd,false);
		}
		if (t > 0) {	//	Keep track of source memory for current forward search results
			prvks[t-1] = frwind; 
			frwind = t;	// Update memory index 
		}
	} }

//  Process recursevly the subtrees created by the previous cycle

	{ for (vind i=0;i<lvind-fvind;i++)   {
		minnv = nvfrwd+lvind-fvind-i;
		maxnv = nvfrwd+lvind-fvind;

		if (minnv <= maxdim && maxnv >= mindim) 
	 		if (!Forward_DepthF_Search(prvks[i],lvind-i,lvind,minnv-1)) return false;
	} }

	return true;
}
예제 #3
0
파일: Varsmbo.cpp 프로젝트: cran/subselect
void wrkspace::initwrkspace(bool pivotall,vind nv,subsetdata* data0,vind lstind,vind nvattop,vind nvatbot,
				vector<vind>& vattop,vector<vind>& vatbot)
{
	vind lastv;
	vector<vind> tlst; 
	subsetdata* newdata=0;
	double trivbnd(-INF);

	p = nv;
	maxim = data0->max();
	if ( !max() ) trivbnd *= -1;
	wrklst.assign(lstind+1,static_cast<subset *>(0));
	if (pivotall)  {
		lastv = nv;
		nwl = p-fp-lp+1;
	}
	else  {
		lastv = nv-1;
		nwl = p-fp-lp;
	}
	if (fp+lp > 0)  {
		tlst.resize(p);
		frontlsts(vatbot,vattop,nvatbot,nvattop,tlst);
		(wrklst[lstind] = new subset(tlst,p,p,data0,false,p))->reorder(tlst);
	}
	else wrklst[lstind] = new subset(p,p,data0,false,p);

	for (vind j=1;j<=nvattop;j++)  {
		newdata = data0->crcopy(p,p-nvatbot-j);
		try {
			if (fp+lp==0) wrklst[lstind-j] = new subset(p,p-nvatbot-j,newdata,true,p);
			else wrklst[lstind-j] = new subset(tlst,p,p-nvatbot-j,newdata,true,p);
		}
		catch (...)   {
			delete newdata;
			throw;
		}
		if (lstind > j) pivot(nvatbot+j,p-nvatbot-j,lstind+1-j,lstind-j,trivbnd);
		else pivot(nvatbot+j,0,lstind+1-j,0,trivbnd);
		delete wrklst[lstind+1-j];
	}

	for (vind j1=nwl-2;j1>=0;j1--) {
		newdata = data0->crcopy(lastv,j1); 
		try {
			if (fp+lp==0) wrklst[j1] = new subset(lastv,j1,newdata,true,p);
			else wrklst[j1] = new subset(tlst,lastv,j1,newdata,true,p);
		}
		catch (...)   {
			delete newdata;
			throw; 		

		}
	}
}
    int solve(long long& res){ /// simplex core
        int i, j, x, y;
        long long u, v, mn, mx;
        for (i = 1; i <= n; i++) down[i] = i;
        for (i = 1; i <= m; i++) link[i] = i + n;

        while (1){ /// phase 1
            x = 0, y = 0, mn = -EPS;
            for (i = 1; i <= m; i++){
                if (rhs[i] < mn) mn = rhs[i], x = i;
            }
            if (x == 0) break;

            for (i = 1; i <= n; i++){
                if (ar[x][i] < -EPS){
                    y = i;
                    if (rand() & 1) break;
                }
            }
            if (y == 0) return INFEASIBLE;
            pivot(x, y, res);
        }

        while (1){ /// phase 2
            x = 0, y = 0, mx = EPS;
            for (i = 1; i <= n; i++){
                if (ar[0][i] > mx) mx = ar[0][i], y = i;
            }
            if (y == 0) break;

            for (i = 1; i <= m; i++){
                if (ar[i][y] > EPS){
                    u = rhs[i] / ar[i][y];
                    if (x == 0 || u < v) x = i, v = u;
                }
            }
            if (x == 0) return UNBOUNDED;
            pivot(x, y, res);
        }

        res *= flag;
        for (int i = 1; i <= m; i++){
            if(link[i] <= n) idx[link[i]] = i;
        }

        for (int i = 1; i <= n; i++) val[i] = rhs[idx[i]];
		return FEASIBLE;
	}
예제 #5
0
static int minimize() {
  int i, ipivot, jpivot;
  mpfr_t t, u;
  mpfr_inits(t, u, (mpfr_ptr)0);

  for (;;) {
    for (jpivot = 1; jpivot <= jmax; jpivot++) {
      if (row[jpivot] == 0) {
	tableau(pivotcolumn[0], 0, jpivot);
	if (mpfr_cmp(pivotcolumn[0], minuseps) < 0) break;
      }
    }
    if (jpivot > jmax) {
      mpfr_clears(t, u, (mpfr_ptr)0);
      return 1;
    }

    mpfr_set(u, large, GMP_RNDN);
    ipivot = 0;
    for (i = 1; i <= m; i++) {
      tableau(pivotcolumn[i], i, jpivot);
      if (mpfr_cmp(pivotcolumn[i], eps) > 0) {
	tableau(t, i, 0);
	mpfr_div(t, t, pivotcolumn[i], GMP_RNDN);
	if (mpfr_cmp(t, u) < 0) { ipivot = i; mpfr_set(u, t, GMP_RNDN); }
      }
    }
    if (ipivot == 0) {
      mpfr_clears(t, u, (mpfr_ptr)0);
      return 0; // the objective function can be minimized to -infinite
    }
    pivot(ipivot, jpivot);
  }
}
예제 #6
0
파일: jailer.c 프로젝트: clefru/jailer
void main(int argc, char **argv) {
  uid_t uid = getuid();
  uid_t gid = getgid();
  char *sandbox_root;
  char **cmd_args;

  if(argc < 3) {
    fprintf(stderr, "Usage: sandbox_root command...\n");
    exit(-1);
  }

  new_root = argv[1];
  cmd_args = argv+2;

  /* 1. Unshare. From here onwards, we have most root-equiv capabilities until we execve-ed, FIXME LWN article here. */
  // FIXME try clone here, just to see if that works too.
  check("unshare", unshare(CLONE_NEWNS | CLONE_NEWUSER | CLONE_NEWPID | CLONE_NEWUTS));
  /* 2. Fork once, so we become the parent of the new process id space and can mount proc */
  fork_once();

  /* 3. Set UID/GID maps, FIXME LWN article here */
  write_file("/proc/self/setgroups", "deny");
  write_file("/proc/self/uid_map", aasprintf("%d %d 1", uid, uid));
  write_file("/proc/self/gid_map", aasprintf("%d %d 1", gid, gid));

  /* 4. Mount minimal fstab */
  mount_fstab();

  /* 5. Pivot into the new root */
  pivot();

  /* 6. Exec */
  check("execve", execv(cmd_args[0], cmd_args));
}
예제 #7
0
파일: sort.c 프로젝트: kanishk7/Code_
void qs(int a[], int l, int r)
{
    if(l == r || l>r)
        return;

    if((r-l) == 1)
    {
        if(a[l] > a[r])
            swap(&a[l],&a[r]);
        return;
    }

    int index = pivot(a,l,r,2);
    swap(&a[index],&a[l]);
    int lt = l+1, rt = r;
    while(lt < rt)
    {
        while(a[lt] < a[l])
            lt++;
        while(a[rt] > a[l])
            rt--;
        if(lt < rt)
        {
            swap(&a[lt],&a[rt]);
            lt++;
            rt--;
        }

    }
    if(l != rt)
        swap(&a[l],&a[rt]);
    qs(a,l,rt-1);
    qs(a,rt+1,r);
    return;
}
예제 #8
0
파일: kthumb.cpp 프로젝트: mcfrisk/kdenlive
//static
uint KThumb::imageVariance(QImage image )
{
    uint delta = 0;
    uint avg = 0;
    uint bytes = image.numBytes();
    uint STEPS = bytes/2;
    QVarLengthArray<uchar> pivot(STEPS);
    const uchar *bits=image.bits();
    // First pass: get pivots and taking average
    for( uint i=0; i<STEPS ; i++ ){
        pivot[i] = bits[2 * i];
#if QT_VERSION >= 0x040700
        avg+=pivot.at(i);
#else
        avg+=pivot[i];
#endif
    }
    avg=avg/STEPS;
    // Second Step: calculate delta (average?)
    for (uint i=0; i<STEPS; i++)
    {
#if QT_VERSION >= 0x040700
        int curdelta=abs(int(avg - pivot.at(i)));
#else
        int curdelta=abs(int(avg - pivot[i]));
#endif
        delta+=curdelta;
    }
    return delta/STEPS;
}
rspfImageViewAffineTransform::rspfImageViewAffineTransform(double rotateDegrees,
                                                             double scaleXValue,
                                                             double scaleYValue,
                                                             double translateXValue,
                                                             double translateYValue,
                                                             double pivotXValue,
                                                             double pivotYValue)
   :m_transform(3,3),
    m_inverseTransform(3,3),
    m_rotation(rotateDegrees),
    m_scale(scaleXValue, scaleYValue),
    m_translate(translateXValue, translateYValue),
    m_pivot(pivotXValue, pivotYValue)
{
   m_transform << 1 << 0 << 0
                << 0 << 1 << 0
                << 0 << 0 << 1;
   
   m_inverseTransform << 1 << 0 << 0
                       << 0 << 1 << 0
                       << 0 << 0 << 1;
   
   rotate(rotateDegrees);
   scale(scaleXValue, scaleYValue);
   translate(translateXValue, translateYValue);
   pivot(m_pivot.x, m_pivot.y);
}
예제 #10
0
파일: tris.c 프로젝트: acekat/PPAR
/**
 * Algorithme de tri rapide parallélisé par tâche
 * @param tab tableau à trié
 * @param len longueur du tableau
 */
void _quick_sort_omp(int *tab, int len)
{
	int i=0, j=len, ipivot;
	
	// pas de tri à faire
	if (len <= 1) 
		return;

	// pas assez d'éléments pour choisir un pivot
	if (len < 3) {
		if (tab[1] < tab[0])
			swap(&tab[1], &tab[0]);
		return;
	}
	
	// choix d'un pivot
	ipivot = pivot(tab, len);
	swap(&tab[0], &tab[ipivot]);

	while(1) {
		do i++; while (i < len && tab[i] < tab[0]);
		do j--; while (tab[j] > tab[0]);
		if (j < i) break;
		swap(&tab[i], &tab[j]);
	}

	swap(&tab[0], &tab[j]);

	#pragma omp task
	_quick_sort_omp(tab, j);
	
	#pragma omp task
	_quick_sort_omp(tab+j+1, len-j-1);
}
예제 #11
0
void CameraRig::setRotation(const glm::quat& transform_rotation) {
    // Get head transform (a child of camera rig object)
    Transform* transform = getHeadTransform();

    if (camera_rig_type_ == FREE) {
        transform->set_rotation(transform_rotation);
    } else if (camera_rig_type_ == YAW_ONLY) {
        glm::vec3 look_at = glm::rotate(transform_rotation,
                glm::vec3(0.0f, 0.0f, -1.0f));
        float yaw = atan2f(-look_at.x, -look_at.z) * 180.0f / M_PI;
        transform->set_rotation(
                glm::angleAxis(yaw, glm::vec3(0.0f, 1.0f, 0.0f)));
    } else if (camera_rig_type_ == ROLL_FREEZE) {
        glm::vec3 look_at = glm::rotate(transform_rotation,
                glm::vec3(0.0f, 0.0f, -1.0f));
        float pitch = atan2f(look_at.y,
                sqrtf(look_at.x * look_at.x + look_at.z * look_at.z)) * 180.0f
                / M_PI;
        float yaw = atan2f(-look_at.x, -look_at.z) * 180.0f / M_PI;
        transform->set_rotation(
                glm::angleAxis(pitch, glm::vec3(1.0f, 0.0f, 0.0f)));
        transform->rotateByAxis(yaw, 0.0f, 1.0f, 0.0f);
    } else if (camera_rig_type_ == FREEZE) {
        transform->set_rotation(glm::quat());
    } else if (camera_rig_type_ == ORBIT_PIVOT) {
        glm::vec3 pivot(getVec3("pivot"));
        transform->set_position(pivot.x, pivot.y,
                pivot.z + getFloat("distance"));
        transform->set_rotation(glm::quat());
        transform->rotateWithPivot(transform_rotation.w,
                transform_rotation.x, transform_rotation.y,
                transform_rotation.z, pivot.x, pivot.y, pivot.z);
    }
}
예제 #12
0
bool VideoThumbnailer::isFrameInteresting(const QImage &frame)
{
    float variance = 0;
    //taken from mplayerthumbs
    uint delta=0;
    uint avg=0;
    uint bytes=frame.numBytes();
    uint STEPS=bytes/2;
    QVarLengthArray<uchar> pivot(STEPS);

    const uchar *bits=frame.bits();
    // First pass: get pivots and taking average
    for( uint i=0; i<STEPS ; i++ ){
        pivot[i]=bits[i*(bytes/STEPS)];
        avg+=pivot[i];
    }
    avg=avg/STEPS;
    // Second Step: calculate delta (average?)
    for (uint i=0; i<STEPS; i++)
    {
        int curdelta=abs(int(avg-pivot[i]));
        delta+=curdelta;
    }
    variance= delta/STEPS;

    return variance > THRESHOLD_FRAME_VARIANCE;
}
예제 #13
0
dgMatrix dgMatrix::Symetric3by3Inverse () const
{
	dgMatrix copy(*this);
	dgMatrix inverse(dgGetIdentityMatrix());
	for (dgInt32 i = 0; i < 3; i++) {
		dgVector den(dgFloat32(1.0f) / copy[i][i]);
		copy[i] = copy[i].CompProduct4(den);
		inverse[i] = inverse[i].CompProduct4(den);
		for (dgInt32 j = 0; j < 3; j++) {
			if (j != i) {
				dgVector pivot(copy[j][i]);
				copy[j] -= copy[i].CompProduct4(pivot);
				inverse[j] -= inverse[i].CompProduct4(pivot);
			}
		}
	}
	
#ifdef _DEBUG
	dgMatrix test(*this * inverse);
	dgAssert(dgAbsf(test[0][0] - dgFloat32(1.0f)) < dgFloat32(0.01f));
	dgAssert(dgAbsf(test[1][1] - dgFloat32(1.0f)) < dgFloat32(0.01f));
	dgAssert(dgAbsf(test[2][2] - dgFloat32(1.0f)) < dgFloat32(0.01f));
#endif

	return inverse;
}
예제 #14
0
Eigen::VectorXf Simplex::run() {
	int piv_col, piv_row;
	while(1){
		piv_col = findPivotColumn();
		//std::cout << " CHOIX PIVOT " << std::endl;
		//std::cout << " simplexe run piv_col : "<< piv_col << std::endl;
		if(piv_col < 0)
		{
			//std::cout<< " STOP " << std::endl;
			getBest(); // optimal
			return best;
		}
		piv_row = findPivotRow(piv_col);
		//std::cout << " simplexe run piv_row : " << piv_row << std::endl;

		if(piv_row < 0)
		{
			//std::cout << " Pas de solution" << std::endl;
			break; //caca
		}
		//std::cout << " val pivot : " << tab(piv_row,piv_col);
		//std::cout << " " << std::endl;
		pivot(piv_row, piv_col);
		//std::cout << tab << std::endl;
	}
	return best;
}
예제 #15
0
/***********************************************************************//**
 * @brief Returns model energy flux between [emin, emax] (units: erg/cm2/s)
 *
 * @param[in] emin Minimum photon energy.
 * @param[in] emax Maximum photon energy.
 * @return Energy flux (erg/cm2/s).
 *
 * Computes
 *
 * \f[
 *    \int_{\tt emin}^{\tt emax} S_{\rm E}(E | t) E \, dE
 * \f]
 *
 * where
 * - [@p emin, @p emax] is an energy interval, and
 * - \f$S_{\rm E}(E | t)\f$ is the spectral model (ph/cm2/s/MeV).
 * The integration is done numerically.
 ***************************************************************************/
double GModelSpectralSmoothBrokenPlaw::eflux(const GEnergy& emin,
                                             const GEnergy& emax) const
{
    // Initialise flux
    double eflux = 0.0;
    
    // Compute only if integration range is valid
    if (emin < emax) {
        
        // Initialise function to integrate
        eflux_kern kernel(prefactor(), index1(), pivot(),
                          index2(), breakenergy(), beta());
        
        // Initialise integral class with function
        GIntegral integral(&kernel);
        
        // Set integration precision
        integral.eps(1.0e-8);
        
        // Calculate integral between emin and emax
        eflux = integral.romberg(emin.MeV(), emax.MeV());
        
        // Convert from MeV/cm2/s to erg/cm2/s
        eflux *= gammalib::MeV2erg;
        
    } // endif: integration range was valid
    
    // Return flux
    return eflux;
}
예제 #16
0
uint MltPreview::imageVariance(QImage image)
{
    if (image.isNull()) return 0;
    uint delta = 0;
    uint avg = 0;
    uint bytes = image.numBytes();
    uint STEPS = bytes / 2;
    QVarLengthArray<uchar> pivot(STEPS);
    kDebug(DBG_AREA) << "Using " << STEPS << " steps\n";
    const uchar *bits=image.bits();
    // First pass: get pivots and taking average
    for( uint i=0; i<STEPS ; i++ ){
        pivot[i] = bits[2 * i];
#if QT_VERSION >= 0x040700
        avg+=pivot.at(i);
#else
        avg+=pivot[i];
#endif
    }
    avg=avg/STEPS;
    // Second Step: calculate delta (average?)
    for (uint i=0; i<STEPS; i++)
    {
#if QT_VERSION >= 0x040700
        int curdelta=abs(int(avg - pivot.at(i)));
#else
        int curdelta=abs(int(avg - pivot[i]));
#endif
        delta+=curdelta;
    }
    return delta / STEPS;
}
예제 #17
0
파일: PIVOT.C 프로젝트: jbailhache/log
main ()
{
int n;
	MATRIX (A, MAX*MAX, MAX, MAX)

	read_matrix (A);

	if (DIM(A,0) != DIM(A,1))
	{
		printf ("La matrice doit etre carree\n");
		return;
	}
	n = DIM(A,0);

	MATRIX (B, MAX*MAX, n, n)

	printf ("Inversion de la matrice : ");
	print_matrix (A);

	pivot (A, B);

	printf ("Matrice inverse : ");
	print_matrix (B);

	ENDMAT ENDMAT
}
예제 #18
0
// Layer
bool CLwoWriter::WriteLayer()
{
	MSG_DEBUG("LAYR");

	// "LAYR" + size
	WriteChunk(CLwoFile::CHUNK_LAYR);

	// layer ID
	ushort layerID = 0; // hack, only support first layer
	WriteShort(layerID);

	// layer Flag
	ushort layerFlag = 0; // hack
	WriteShort(layerFlag);

	// layer Pivot
	Vector3D pivot(3); // Pivot
	pivot[0] = 0.0f;
	pivot[1] = 0.0f;
	pivot[2] = 0.0f;
	WriteVector3D(pivot);

	// layer Name
	WriteString(""); // Layer Name

	// no parent

	return true;
}
예제 #19
0
void forwardEliminationStep(double* localRows, float* pvtime)
{
	// Fill up this array with the ids of local rows. Will be used in the FE computation to quickly
	// check if indices of local rows are bigger than pivot row.
	int localRowIds[MAX_N];
	int i = 0;
	int j;
	for(j = 0; j < N; j++)
	{
		if(getRowPID(j) == PID) 
		{
			localRowIds[i] = j;	
			i++;
		}
	}
	if(i != RPP) printf("local row number %d != RPP %d!!\n", i, RPP); // This should never happen.
	
	for(j = 0; j < N; j++)
	{
		double rowj[MAX_N];
		double* rowPtr = getLocalRow(j, localRows);
		
		int rowSource = getRowPID(j);
		
		// Pivot
		pivot(localRows, rowPtr, j, rowSource, localRowIds, pvtime);
		
		if(rowPtr != NULL)
		{
			memcpy(rowj, rowPtr, (N + 1) * sizeof(double));
		}
		
		// Broadcast the row.
		MPI_Bcast(rowj, N + 1, MPI_DOUBLE, rowSource, MPI_COMM_WORLD);
		
		// Compute new coefficients for rows after j
		int i;
		for(i = 0; i < RPP; i++)
		{
			double* rowi = &localRows[i * (N + 1)];
			double mult = -(rowi[j]/rowj[j]);
			//printf("NODE %d LOCAL ROW %d FIRST VAL %11.4e\n", PID, i, rowi[0]);
			
			if(localRowIds[i] > j)
			{
				int k;
				for(k = 0; k < N + 1; k++)
				{
					if(k == j) rowi[k] = 0;
					else rowi[k] = mult * rowj[k] + rowi[k];
					//double v = mult * rowj[k] + rowi[k];
					
					// Kind of hack but useful for visually debugging output matrix.
					//if(rowi[k] < 0.00000000000001) rowi[k] = 0;
				}
			}
		}
	}
}
예제 #20
0
  m2::RectD SymbolElement::GetBoundRect() const
  {
    // Skip for one pixel on every border.
    m2::PointD const sz(m_symbolRect.SizeX() - 2, m_symbolRect.SizeY() - 2);
    m2::PointD const posPt = computeTopLeft(sz, pivot(), position());

    return m2::RectD(posPt, posPt + sz);
  }
예제 #21
0
파일: qsort-m2.cpp 프로젝트: jzou2000/codex
void QuickSort<T>::sort(Iterator begin, Iterator end)
{
    typename QuickSort<T>::Iterator m = pivot(begin, end);
    if (m - begin > 1)
        sort(begin, m);
    if (end - m > 1)
        sort(m + 1, end);
}
예제 #22
0
void dgUpVectorConstraint::InitPinDir (const dgVector& pin)
{

	const dgMatrix& matrix = m_body0->GetMatrix();

	dgVector pivot (matrix.m_posit); 
	SetPivotAndPinDir (pivot, pin);

}
예제 #23
0
void quicksort(int arr_element[],int first_indx,int last_indx)
{
	if(first_indx < last_indx) {
			int pivot_pos;
			pivot_pos=pivot(arr_element,first_indx,last_indx);
			quicksort(arr_element,first_indx,pivot_pos-1);
			quicksort(arr_element,pivot_pos+1,last_indx);
		}
}
예제 #24
0
void UDP_Socket::quicksort(int lowerBound, int upperBound)
{
	//End case recursion.
	if (lowerBound >= upperBound)
		return;
	int current = pivot(lowerBound, upperBound);
	quicksort(lowerBound, current - 1);
	quicksort(current + 1, upperBound);
}
예제 #25
0
glm::mat4 AreaNode::calcTransform()
{
    glm::vec3 pos(m_RelViewport.tl.x, m_RelViewport.tl.y, 0);
    glm::vec3 pivot(getPivot().x, getPivot().y, 0);
    glm::mat4 transform = glm::translate(glm::mat4(1.0f), pos);
    transform = glm::translate(transform, pivot);
    transform = glm::rotate(transform, (180.f/PI)*m_Angle, glm::vec3(0,0,1));
    transform = glm::translate(transform, -pivot);
    return transform;
}
예제 #26
0
void Transform::rotateWithPivot(float w, float x, float y, float z,
        float pivot_x, float pivot_y, float pivot_z) {
    glm::quat rotation(w, x, y, z);
    rotation_ = rotation * rotation_;
    glm::vec3 pivot(pivot_x, pivot_y, pivot_z);
    glm::vec3 relative_position = position_ - pivot;
    relative_position = glm::rotate(rotation, relative_position);
    position_ = relative_position + pivot;
    invalidate();
}
예제 #27
0
/*
 * 矩阵M的结构是
 * |	y 	|	x	|b|
 * |1	   0|		|
 * |   1   0|		|
 * |	   1|		|
 * |下面接m行		|
 * principad pivoting methiod不停的交换y区的和x区的主元,直到b都为正
 * 或者算法无法继续推进(返回的列和上次的一样)。
 * x 是一个2n向量,前面的n个元素是解x,后面y。skip是M的行距。
 * 成功返回1,失败0.
 */
int lcp_pivotBlock(real *M,real *x,int n,int m,int skip)
{
	int i,row,prev,s;
	int *base = (int *)malloc(2*n*sizeof(int));
	/*
	 * base用来标识基向量
	 * |<--n-->|<--n-->|
	 * |   y   |   x   |
	 * |1111111|0000000|
	 * 初始化的时候将基向量都设置为y区
	 */
	for(i=0;i<n;i++){
		base[i] = 1;
		base[n+i] = 0;
	}
	prev = -1;
	s = 0;
	/*
	 *FIXBUG: 算法会陷入死循环,目前简单的加一个简单限制s++<2n
	 */
	while( (row=last_negative(M,n,skip)) != prev && row!=-1 && s++<=2*n){
		prev = row;
		/*
		 * 算法会确保基向量总是等于1,在x区和y区选择一个基向量
		 */
		if( M[row*skip+row] != 1){
			base[row] = 1;
			base[row+n] = 0;
			if(!pivot(M,row,row,n,m,skip))
				break;
		}else if( M[row*skip+row+n] != 1 ){
			base[row] = 0;
			base[row+n] = 1;
			if(!pivot(M,row,row+n,n,m,skip))
				break;
		}
	}

	//printf("final result:\n");
	//printM(M,NULL,n+m,skip);
	return check_get_result_and_free_base(M,base,x,n,skip);
}
예제 #28
0
void Transform::rotateByAxisWithPivot(float angle, float axis_x, float axis_y,
        float axis_z, float pivot_x, float pivot_y, float pivot_z) {
    glm::quat axis_rotation = glm::angleAxis(angle,
            glm::vec3(axis_x, axis_y, axis_z));
    rotation_ = axis_rotation * rotation_;
    glm::vec3 pivot(pivot_x, pivot_y, pivot_z);
    glm::vec3 relative_position = position_ - pivot;
    relative_position = glm::rotate(axis_rotation, relative_position);
    position_ = relative_position + pivot;
    invalidate();
}
예제 #29
0
/** Quick Sort **/
void Sort::quick_sort( int a[], int first, int last ) 
{
    int pivot_element;
 
    if(first < last)
    {
        pivot_element = pivot(a, first, last);
        quick_sort(a, first, pivot_element-1);
        quick_sort(a, pivot_element+1, last);
    }
}
예제 #30
0
파일: sort.c 프로젝트: MarcoCBA/Proyectos
unsigned int rand_quick_sort_rec(int a[], unsigned int izq, unsigned int der) {
    if (izq < der) {
        resultado= pivot(a,izq,der);
        if (resultado.dato > 0) {
            rand_quick_sort_rec(a,izq,resultado.dato - 1);
            rand_quick_sort_rec(a,resultado.dato + 1,der);
        }
    }
    resultado.comp = resultado.comp + 1;
    return resultado.comp;
}