Пример #1
0
// TO-DO: Remove this ENTIRE queue system.
int CSharedMemQueue::PutData(Packet *pkt, int16 uid /*= -1*/)
{
	BYTE BlockMode;
	int index = 0, count = 0;
	short size = pkt->size() + 1;

	if ((DWORD)size > m_wOffset)
	{
		TRACE("DataSize Over.. - %d bytes\n", pkt->size());
		return SMQ_PKTSIZEOVER;
	}

	do {
		if( m_pHeader->RearMode == W ) {
			aa();
			count++;
			continue;
		}

		m_pHeader->RearMode = W;
		m_pHeader->WritePid = ::GetCurrentThreadId();	// writing side (game server) is multi thread

		aa();	// no operation function

		if( m_pHeader->WritePid != ::GetCurrentThreadId() ) {
			count++;
			continue;
		}

		LONG pQueue = m_lReference + (m_pHeader->Rear * m_wOffset);
		BlockMode = GetByte( (char*)pQueue, index );
		if( BlockMode == WR && m_pHeader->nCount >= MAX_COUNT-1 ) {
			m_pHeader->RearMode = WR;
			return SMQ_FULL;
		}

		index = 0;
		char *queue = ((char *)pQueue);
		queue[index++] = WR;	// Block Mode Set to WR	-> Data Exist
		SetShort(queue, size, index);
		SetShort(queue, uid, index);
		queue[index++] = pkt->GetOpcode();
		if (pkt->size() > 0)
			memcpy(queue+index, pkt->contents(), size);
		m_pHeader->nCount++;

		m_pHeader->Rear = (m_pHeader->Rear + 1) % MAX_COUNT;
		m_pHeader->RearMode = WR;
		
		break;

	} while( count < 50 );
	if( count >= 50 ) {
		m_pHeader->RearMode = WR;
		return SMQ_WRITING;
	}

	return 1;
}
Пример #2
0
void mul(Ring_Element& ans,const Ring_Element& a,const Ring_Element& b)
{
  if (a.rep!=b.rep)   { throw rep_mismatch(); }
  if (a.FFTD!=b.FFTD) { throw pr_mismatch();  }
  ans.partial_assign(a);
  if (ans.rep==evaluation)
    { // In evaluation representation, so we can just multiply componentwise
      for (int i=0; i<(*ans.FFTD).phi_m(); i++)
        { Mul(ans.element[i],a.element[i],b.element[i],(*a.FFTD).get_prD()); }
    }
  else if ((*ans.FFTD).get_twop()!=0)
    { // This is the case where m is not a power of two

      // Here we have to do a poly mult followed by a reduction
      // We could be clever (e.g. use Karatsuba etc), but instead
      // we do the school book method followed by term re-writing

      // School book mult
      vector<modp> aa(2*(*a.FFTD).phi_m());
      for (int i=0; i<2*(*a.FFTD).phi_m(); i++)
        { assignZero(aa[i],(*a.FFTD).get_prD()); }
      modp temp;
      for (int i=0; i<(*a.FFTD).phi_m(); i++)
        { for (int j=0; j<(*a.FFTD).phi_m(); j++)
	    { Mul(temp,a.element[i],b.element[j],(*a.FFTD).get_prD()); 
              int k=i+j;
              Add(aa[k],aa[k],temp,(*a.FFTD).get_prD());
            }
        }
      // Now apply reduction, assumes Ring.poly is monic
      for (int i=2*(*a.FFTD).phi_m()-1; i>=(*a.FFTD).phi_m(); i--)
        { reduce_step(aa,i,*a.FFTD);
          assignZero(aa[i],(*a.FFTD).get_prD()); 
        }
     // Now stick into answer
     for (int i=0; i<(*ans.FFTD).phi_m(); i++)
       { ans.element[i]=aa[i]; }
    }
  else if ((*ans.FFTD).get_twop()==0)
    { // m a power of two case
      Ring_Element aa(*ans.FFTD,ans.rep);
      modp temp;
      for (int i=0; i<(*ans.FFTD).phi_m(); i++)
        { for (int j=0; j<(*ans.FFTD).phi_m(); j++)
            { Mul(temp,a.element[i],b.element[j],(*a.FFTD).get_prD());
              int k=i+j;
              if (k>=(*ans.FFTD).phi_m())
                 { k-=(*ans.FFTD).phi_m();
                   Negate(temp,temp,(*a.FFTD).get_prD());
                 }
              Add(aa.element[k],aa.element[k],temp,(*a.FFTD).get_prD());
            }
        }
      ans=aa;
    }
  else
    { throw not_implemented(); }
}
Пример #3
0
int CSharedMemQueue::PutData(char *pBuf, int size)
{
	char logstr[256];
	memset( logstr, 0x00, 256);
	BYTE BlockMode;
	int index = 0, count = 0;

	if( (DWORD)size > m_wOffset ) {
		sprintf( logstr, "DataSize Over.. - %d bytes\r\n", size );
		LogFileWrite( logstr );
		return SMQ_PKTSIZEOVER;
	}

	do {
		if( m_pHeader->RearMode == W ) {
			aa();
			count++;
			continue;
		}

		m_pHeader->RearMode = W;
		m_pHeader->WritePid = ::GetCurrentThreadId();	// writing side (game server) is multi thread

		aa();	// no operation function

		if( m_pHeader->WritePid != ::GetCurrentThreadId() ) {
			count++;
			continue;
		}

		LONG pQueue = m_lReference + (m_pHeader->Rear * m_wOffset);
		BlockMode = GetByte( (char*)pQueue, index );
		if( BlockMode == WR && m_pHeader->nCount >= MAX_COUNT-1 ) {
			m_pHeader->RearMode = WR;
			return SMQ_FULL;
		}

		index = 0;
		SetByte( (char*)pQueue, WR, index );	// Block Mode Set to WR	-> Data Exist
		SetShort( (char*)pQueue, size, index );
		SetString( (char*)pQueue, pBuf, size, index );

		m_pHeader->nCount++;

		m_pHeader->Rear = (m_pHeader->Rear + 1) % MAX_COUNT;
		m_pHeader->RearMode = WR;
		
		break;

	} while( count < 50 );
	if( count >= 50 ) {
		m_pHeader->RearMode = WR;
		return SMQ_WRITING;
	}

	return 1;
}
Пример #4
0
void Batched::DrawQuad(Vector2 pos, Vector2 size, float rotation, Texture& tex, int atl)
{
	int i = atl%64;
	int j = atl/64;
	Rect aa(i/64.0, (j*32.0)/tex.height, 1/64.0, 32.0/tex.height);
	innerDraw(pos, size, rotation, tex, aa);
}
Пример #5
0
void TRegularPolygon::get_triangles(const Math::Triangle<2>::put_delegate_t &f, double resolution) const
{
    static const double epsilon = 1e-8;
    const double rstep = get_radial_step(resolution);
    const double astep1 = 2.0 * M_PI / (double)_edge_cnt;

    for (double r = 0 ; r < _radius - epsilon; r += rstep)
    {
        for (double a1 = 0; a1 < 2.0 * M_PI - epsilon; a1 += astep1)
        {
            Math::Vector2 a(cos(_angle + a1), sin(_angle + a1));
            Math::Vector2 aa(a * r);
            Math::Vector2 ab(a * (r + rstep));

            Math::Vector2 b(cos(_angle + a1 + astep1), sin(_angle + a1 + astep1));
            Math::Vector2 ba(b * r);
            Math::Vector2 bb(b * (r + rstep));

            f(Math::Triangle<2>(aa, ba, bb));
            f(Math::Triangle<2>(bb, ab, aa));
        }

    }

}
Пример #6
0
void KDTreeTestCase::singleSearchExact() {
    
    //make sure we can compare points accuratly
    std::vector<double> a = {1.0,2.0,3.0};
    std::vector<double> b = {3.0,2.0,1.0}; 

    //Technically i could do 16 different tests but for now
    //I'm going to test the two that are important to this
    //test.  If i were to keep going, i would have separate
    //tests for points
    Point<3, double, std::string> aa(a, "hello");
    Point<3, double, std::string> aa_2(a, "hello");
    Point<3, double, std::string> ba(b, "goodbye");

    CPPUNIT_ASSERT_MESSAGE("make sure points can be compared with similiar points",
            aa == aa_2);

    CPPUNIT_ASSERT_MESSAGE("make sure points can be compared with different points",
            aa != ba);
  
    Point<_N_, double, std::string> pt;
    search_ptr<_N_, double, std::string> ret;
    // Grab a bunch of random known point and look for it in the tree
    for (int test = 0; test < _N_1_SEARCH_TEST_; test++) {
        pt = points->at(rand() % _N_TEST_POINTS_);

        ret = tree->search(pt);

        search_iter<_N_, double, std::string> pos; 
        for( pos = ret->begin(); pos != ret->end(); pos++) {
            CPPUNIT_ASSERT_MESSAGE("checking if point transferred ok",
                pos->second == pt);
        }
    }
}
Пример #7
0
void generateTF(int trans, Eigen::Quaternionf &R,  Eigen::Vector3f &t, Eigen::Matrix3f &mR)
{
  float strengthR=(trans%3)*0.05;
  trans/=3;
  float strengthT=(trans%3)*0.05;
  trans/=3;

  int temp=trans%8;
  Eigen::Vector3f axis;
  axis(0) = temp&1?1:0;
  axis(1) = temp&2?1:0;
  axis(2) = temp&4?1:0;
  trans/=8;

  Eigen::AngleAxisf aa(strengthR,axis);
  R = aa.toRotationMatrix();
  mR= R.toRotationMatrix();
  R = mR;

  t(0) = temp&1?1:0;
  if(temp&2) t(0)=-t(0);
  t(1) = temp&4?1:0;
  if(temp&8) t(1)=-t(1);
  t(2) = temp&16?1:0;
  if(temp&32) t(2)=-t(2);
  trans/=64;

  t*=strengthT;
}
Пример #8
0
void *hi(void *ptr)
{
     int a = *(int *)ptr;			
	int b;
	pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
	
	pthread_mutex_lock(&mutex1);
	
//	printf("into hi function\n");
	// klee_make_symbolic(&a, sizeof(a), "input");
	/*
	if(a > 5)
		printf("nice follow your heart\n");
		*/
	if(b > 100)
			if(a > 20)
				printf("int hi00000\n");
			else
				printf("int hi111111\n");
	else
		aa(a);
//	int a = 10;
//	if(a > 20)
//		printf("hfas\n");		
/*
	 if(a > 5)
		printf("hell");
	 else
		printf("cry");

*/

	pthread_mutex_unlock(&mutex1);
//	printf("out hi function\n");
}
Пример #9
0
void m2::multABt::calc(matrixn& c, matrixn const& a, matrixn const& b) const
{
	if(&a==&c)
	{
		matrixn aa(a);
		calc(c, aa,b);
	}

	if(&b==&c)
	{
		matrixn bb(b);
		calc(c, a,bb);
	}

    assert( a.cols()==b.cols() );
    c.setSize( a.rows(), b.rows() );

    for( int i=0; i<a.rows(); i++ )
    for( int j=0; j<b.rows(); j++ )
    {
        c[i][j] = 0;
        for( int k=0; k<a.cols(); k++ )
            c[i][j] += a[i][k] * b[j][k];
    }
    
}
Пример #10
0
int main()
{

    // ========================================================================
    std::cout << "Create an amino acid" << std::endl;

    libaas::aminoAcids::AminoAcid aa('C');

    // ========================================================================
    std::cout << "Set a stoichiometry configuration" << std::endl;

// start creating a custom stoichiometry configuration
    libaas::StoichiometryConfigImpl::StoichiometryConfigImplKeyType custom_key =
            "My_Stoichiometry_Configuration 1";
    libaas::StoichiometryConfigImpl customConfig(custom_key);
    // create custom element ...
    libaas::elements::ElementImpl customElement(
        libaas::elements::ElementImpl::getNextId(), "C", 6);
    customElement.addIsotope(13.0034, 1.0);
    libaas::elements::Element customElementRef(customElement);
    // ... and add by instance of an element
    customConfig.insertElement(
        libaas::elements::Element(customElement.getId()));
    addStoichiometryConfig(customConfig);

    aa.setStoichiometryConfig(custom_key);

    // ========================================================================
    std::cout << "Retrieve the stoichiometry" << std::endl;

    aa.getStoichiometry();

    return 0;
}
Пример #11
0
void
blah (int code1, int code2)
{
  int i;
  int n_sets;

  n_sets = (int) (code1 == 32);
  if (code2 == 64) goto L2; else goto L3;

L2:
  aa ();

L3:
  if (n_sets > 1) goto L4; else goto L10;

L4:
  aos ();
  i = 0;
  goto L24;

L10:
  if (n_sets > 0) goto L25; else goto L8;

L25:
  i = 0;

L24:
  aob ();
  i = i + 1;
  if (i < n_sets) goto L24; else goto L8;

L8:
  return;
}
Пример #12
0
void AMSRotMat::YParity(){
  number nn[3][3]={{1,0,0},{0,-1,0},{0,0,1}};
  AMSRotMat aa(nn);
  (*this)=(*this)*aa;

  return;
}
Пример #13
0
bool SerializeAttachment(Grid& grid, TAttachment& attachment,
						 typename geometry_traits<TElem>::iterator iterBegin,
						 typename geometry_traits<TElem>::iterator iterEnd,
						 BinaryBuffer& out)
{
	if(!grid.has_attachment<TElem>(attachment))
		return false;

//	copy data
	Grid::AttachmentAccessor<TElem, TAttachment> aa(grid, attachment);
	typedef typename TAttachment::ValueType ValueType;
	
//	write a magic number at the beginning and at the end.
	int magicNumber = 8304548;
	out.write((char*)&magicNumber, sizeof(int));

//TODO: remove the following test code.
//	test: write a number-value to check whether it is send correctly
/*
	number tNum = 1247.001234;
	out.write((char*)&tNum, sizeof(number));
*/	
	for(; iterBegin != iterEnd; ++iterBegin)
	{
		out.write((char*)&aa[*iterBegin], sizeof(ValueType));
	}
	out.write((char*)&magicNumber, sizeof(int));

	return true;
}
Пример #14
0
int bag(vector< vector< map<int,float> > > & tests, vector<float> & weight){
     vector< map<int,float> > aa(USER_NUM);
     for(int k = 0; k < tests.size(); ++k){
          for(int u = 0; u < tests[k].size(); ++u){
               if(tests[k][u].empty()) continue;
               for(map<int,float>::iterator j = tests[k][u].begin(); j != tests[k][u].end(); ++j){
                    int item = j->first;
                    if(aa[u].find(item) == aa[u].end()) aa[u][item] = 0;
                    aa[u][item] += (float)(j->second) * weight[k];
               }
          }
     }
     ofstream out("result-train.txt");
     for(int i = 0; i < aa.size(); ++i){
          if(aa[i].empty()) continue;
          vector< pair<int,float> > reco(aa[i].begin(), aa[i].end());
          sort(reco.begin(), reco.end(), GreaterSecond<int,float>);
          //if(reco.size() > 20) reco.erase(reco.begin() + 20, reco.end());
          //postProcessByLanguage(i, reco);
          out << i << ":" << reco[0].first;
          for(int k = 1; k < reco.size() && k < 20; ++k)
               out << "," << reco[k].first;
          out << endl;
     }
     out.close();
     return score(aa);
}
Пример #15
0
DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
                                          FPDF_FORMHANDLE hHandle,
                                          int aaType) {
  if (!hHandle)
    return;
  CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
  UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
  CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
  if (!pPDFPage)
    return;
  if (pSDKDoc->GetPageView(pPage, FALSE)) {
    CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
    CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
    CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict;
    CPDF_AAction aa(pPageDict->GetDictBy("AA"));
    if (FPDFPAGE_AACTION_OPEN == aaType) {
      if (aa.ActionExist(CPDF_AAction::OpenPage)) {
        CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
        pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
      }
    } else {
      if (aa.ActionExist(CPDF_AAction::ClosePage)) {
        CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
        pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
      }
    }
  }
}
void motion3s(Eigen::Matrix3f &rot, Eigen::Vector3f &tr)
{
  Eigen::Vector3f n=Eigen::Vector3f::Identity();
  Eigen::AngleAxisf aa(0.05f,n);
  rot = aa.toRotationMatrix();
  tr.fill(0);
}
Пример #17
0
std::string to_string(big_integer const& a)
{
    std::string res = "";
    big_integer aa (a);
    big_integer bb (0);
    big_integer cc (0);
    big_integer dd (0);
    if (a.flag == 1) {
        aa.flag = false;
    }
    if (a == big_integer(0)) return "0";
    while ((aa) > big_integer(0))
    {
        bb = aa / big_integer(1000000000);
        cc = bb * big_integer(1000000000);
        dd = aa - cc;
        aa = bb;
        for (int i = 0; i < 9; i++)
        {
            res += dd.data[0] % 10 + 48;
            dd.data[0] /= 10;
        }
    }
    while (res[res.size() - 1] == '0') res.pop_back();
    if (a.flag == 1) {
        res+='-';
    }
    for (int  i = 0; i < res.size()/2; ++i)
    {
        std::swap(res[i], res[res.size()-1-i]);
    }
    return res;
}
Пример #18
0
  HyperGraphElementAction* VertexSE3DrawAction::operator()(HyperGraph::HyperGraphElement* element, 
                 HyperGraphElementAction::Parameters* params_){
    if (typeid(*element).name()!=_typeName)
      return 0;
    if (! _cacheDrawActions){
      _cacheDrawActions = HyperGraphActionLibrary::instance()->actionByName("draw");
    }

    refreshPropertyPtrs(params_);
    if (! _previousParams)
      return this;
    
    if (_show && !_show->value())
      return this;

    VertexSE3* that = static_cast<VertexSE3*>(element);

    glColor3f(0.5,0.5,0.8);
    glPushMatrix();
    glTranslatef(that->estimate().translation().x(),that->estimate().translation().y(),that->estimate().translation().z());
    AngleAxisd aa(that->estimate().rotation());
    glRotatef(RAD2DEG(aa.angle()),aa.axis().x(),aa.axis().y(),aa.axis().z());
    if (_triangleX && _triangleY){
      drawTriangle(_triangleX->value(), _triangleY->value());
    }
    CacheContainer* caches=that->cacheContainer();
    if (caches){
      for (CacheContainer::iterator it=caches->begin(); it!=caches->end(); it++){
  Cache* c = it->second;
  (*_cacheDrawActions)(c, params_);
      }
    }
    glPopMatrix();
    return this;
  }
Пример #19
0
// static
bool GLinearProgramming::simplexMethod(GMatrix* pA, const double* pB, int leConstraints, int geConstraints, const double* pC, double* pOutX)
{
	// Set up the matrix in the expected form
	if((size_t)leConstraints + (size_t)geConstraints > pA->rows())
		throw Ex("The number of constraints must be >= leConstraints + geConstraints");
	GMatrix aa(pA->rows() + 3, pA->cols() + 2);
	aa.setAll(0.0);
	aa[1][1] = 0.0;
	GVec::copy(aa.row(1).data() + 2, pC, pA->cols());
	for(size_t i = 1; i <= pA->rows(); i++)
	{
		GVec::copy(aa.row(i + 1).data() + 2, pA->row(i - 1).data(), pA->cols());
		GVec::multiply(aa.row(i + 1).data() + 2, -1.0, pA->cols());
		aa[i + 1][1] = pB[i - 1];
	}

	// Solve it
	int icase;
	GTEMPBUF(int, iposv, aa.rows());
	GTEMPBUF(int, izrov, aa.cols());
	simplx(aa, (int)pA->rows(), (int)pA->cols(), leConstraints, geConstraints, &icase, izrov, iposv);

	// Extract the results
	if(icase)
		return false; // No solution. (icase gives an error code)
	GVec::setAll(pOutX, 0.0, pA->cols());
	for(size_t i = 1; i <= pA->rows(); i++)
	{
		int index = iposv[i];
		if(index >= 1 && index <= (int)pA->cols())
			pOutX[index - 1] = aa[i + 1][1];
	}
	return true;
}
Пример #20
0
/* this function is called from field renderers for all field nodes */
void Renderer::setNodeGlData(const shared_ptr<Node>& n){
	bool scaleRotations=(rotScale!=1.0 && scaleOn);
	bool scaleDisplacements=(dispScale!=Vector3r::Ones() && scaleOn);
	const bool isPeriodic=scene->isPeriodic;

	if(!n->hasData<GlData>()) n->setData<GlData>(make_shared<GlData>());
	GlData& gld=n->getData<GlData>();
	// inside the cell if periodic, same as pos otherwise
	Vector3r cellPos=(!isPeriodic ? n->pos : scene->cell->canonicalizePt(n->pos,gld.dCellDist)); 
	bool rendered=!pointClipped(cellPos);
	// this encodes that the node is clipped
	if(!rendered){ gld.dGlPos=Vector3r(NaN,NaN,NaN); return; }
	if(setRefNow || isnan(gld.refPos[0])) gld.refPos=n->pos;
	if(setRefNow || isnan(gld.refOri.x())) gld.refOri=n->ori;
	const Vector3r& pos=n->pos; const Vector3r& refPos=gld.refPos;
	const Quaternionr& ori=n->ori; const Quaternionr& refOri=gld.refOri;
	// if no scaling and no periodic, return quickly
	if(!(scaleDisplacements||scaleRotations||isPeriodic)){ gld.dGlPos=Vector3r::Zero(); gld.dGlOri=Quaternionr::Identity(); return; }
	// apply scaling
	gld.dGlPos=cellPos-n->pos;
	// add scaled translation to the point of reference
	if(scaleDisplacements) gld.dGlPos+=((dispScale-Vector3r::Ones()).array()*Vector3r(pos-refPos).array()).matrix(); 
	if(!scaleRotations) gld.dGlOri=Quaternionr::Identity();
	else{
		Quaternionr relRot=refOri.conjugate()*ori;
		AngleAxisr aa(relRot);
		aa.angle()*=rotScale;
		gld.dGlOri=Quaternionr(aa);
	}
}
 void
 withReference()
 {
     int xx = 4711;
     Chamaeleon<int&> aa(xx);
     CPPUNIT_ASSERT_EQUAL( xx, aa.unHide() );
 }
 void
 withPointer()
 {
     A* aPtr = new A();
     Chamaeleon<A*> aa(aPtr);
     CPPUNIT_ASSERT_EQUAL( 1, aa.unHide()->test() );
 }
Пример #23
0
void OpenGLRenderer::setBodiesDispInfo(){
	if(scene->bodies->size()!=bodyDisp.size()) {
		bodyDisp.resize(scene->bodies->size());
		for (unsigned k=0; k<scene->bodies->size(); k++) bodyDisp[k].hidden=0;}
	bool scaleRotations=(rotScale!=1.0);
	bool scaleDisplacements=(dispScale!=Vector3r::Ones());
	FOREACH(const shared_ptr<Body>& b, *scene->bodies){
		if(!b || !b->state) continue;
		size_t id=b->getId();
		const Vector3r& pos=b->state->pos; const Vector3r& refPos=b->state->refPos;
		const Quaternionr& ori=b->state->ori; const Quaternionr& refOri=b->state->refOri;
		Vector3r cellPos=(!scene->isPeriodic ? pos : scene->cell->wrapShearedPt(pos)); // inside the cell if periodic, same as pos otherwise
		bodyDisp[id].isDisplayed=!pointClipped(cellPos);
		// if no scaling and no periodic, return quickly
		if(!(scaleDisplacements||scaleRotations||scene->isPeriodic)){ bodyDisp[id].pos=pos; bodyDisp[id].ori=ori; continue; }
		// apply scaling
		bodyDisp[id].pos=cellPos; // point of reference (inside the cell for periodic)
		if(scaleDisplacements) bodyDisp[id].pos+=dispScale.cwiseProduct(Vector3r(pos-refPos)); // add scaled translation to the point of reference
		if(!scaleRotations) bodyDisp[id].ori=ori;
		else{
			Quaternionr relRot=refOri.conjugate()*ori;
			AngleAxisr aa(relRot);
			aa.angle()*=rotScale;
			bodyDisp[id].ori=refOri*Quaternionr(aa);
		}
	}
}
Пример #24
0
//!Precompute relative rotations (and precompute ScGeom3D)
void ScGeom6D::precomputeRotations(const State& rbp1, const State& rbp2, bool isNew, bool creep){
	if (isNew) {
		initRotations(rbp1,rbp2);
	} else {
		Quaternionr delta((rbp1.ori * (initialOrientation1.conjugate())) * (initialOrientation2 * (rbp2.ori.conjugate())));
		delta.normalize();
		if (creep) delta = delta * twistCreep;
		AngleAxisr aa(delta); // axis of rotation - this is the Moment direction UNIT vector; // angle represents the power of resistant ELASTIC moment
		//Eigen::AngleAxisr(q) returns nan's when q close to identity, next tline fixes the pb.
// add -DYADE_SCGEOM_DEBUG to CXXFLAGS to enable this piece or just do
// #define YADE_SCGEOM_DEBUG //(but do not commit with that enabled in the code)
#ifdef YADE_SCGEOM_DEBUG
		if (isnan(aa.angle())) {
			cerr<<"NaN angle found in angleAxisr(q), for quaternion "<<delta<<", after quaternion product"<<endl;
			cerr<<"rbp1.ori * (initialOrientation1.conjugate())) * (initialOrientation2 * (rbp2.ori.conjugate()) with quaternions :"<<endl;
			cerr<<rbp1.ori<<" * "<<initialOrientation1<<" * "<<initialOrientation2<<" * "<<rbp2.ori<<endl<<" and sub-products :"<<endl<<rbp1.ori * (initialOrientation1.conjugate())<<" * "<<initialOrientation2 * (rbp2.ori.conjugate())<<endl;
			cerr <<"q.w (before normalization) "<<delta.w();
			delta.normalize();
			cerr <<"q.w (after) "<<delta.w()<<endl;
			AngleAxisr bb(delta);
			cerr<<delta<<" "<<bb.angle()<<endl;
		}
#else
		if (isnan(aa.angle())) aa.angle()=0;
#endif
		if (aa.angle() > Mathr::PI) aa.angle() -= Mathr::TWO_PI;   // angle is between 0 and 2*pi, but should be between -pi and pi
		twist = (aa.angle() * aa.axis().dot(normal));
		bending = Vector3r(aa.angle()*aa.axis() - twist*normal);
	}
}
Пример #25
0
bool fmd5app::heartbeat()
{
	int a = 0xA0F980;
	stringc aa(a, 16);
	stringc bb = fitoa16(a);
	stringc tmp = fmd5(bb.c_str(), bb.size());

	uint32_t cc32 = fcrc32(bb.c_str(), bb.size());
	uint32_t cc32a = fcrc32a(bb.c_str(), bb.size());
	FUSE(cc32);
	FUSE(cc32a);
	stringc sha1 = fsha1(bb.c_str(), bb.size());
    FUSE(sha1);
    
    uint8_t src[]="12345678";
    uint8_t des[8];
    uint8_t ddes[8];
    fdes("12345678", src, 8, des);
    fundes("12345678", des, 8, ddes);
    stringc des1 = fdes("12345678", "12345678");
    stringc src1 = fundes("12345678", des1);
    FUSE(src1);

   
    uint8_t aes_src[]="1234567812345678";
    uint8_t aes_des[16];
    uint8_t aes_ddes[16];
    faes("12345678", aes_src, 16, aes_des);
    funaes("12345678", aes_des, 16, aes_ddes);
    stringc aes_des1 = faes("12345678", "1234567812345678");
    stringc aes_src1 = funaes("12345678", aes_des1);
    FUSE(aes_src1);
    
	return true;
}
Пример #26
0
int main()
{
  typedef CGAL::Surface_mesh<Point_3> Mesh;
  Mesh mesh;
  test_validity(mesh);
  //                                  triangle  quad    tetra   hexa
  test<Mesh>("data/triangle.off",     true,     false,  false,  false );
  test<Mesh>("data/quad.off",         false,    true,   false,  false );
  test<Mesh>("data/tetrahedron.off",  false,    false,  true,   false );
  test<Mesh>("data/cube.off",         false,    false,  false,  false );
  test<Mesh>("data/cube-quads.off",   false,    false,  false,  true );

  typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;

  Point_3 a(0,0,0), b(1,0,0), c(1,1,0), d(0,1,0);
  Point_3 aa(0,0,1), bb(1,0,1), cc(1,1,1), dd(0,1,1);
  Mesh m;
  halfedge_descriptor hd;
  hd = CGAL::make_triangle(a,b,c,m);
  assert(CGAL::is_isolated_triangle(hd,m));
  assert(CGAL::is_valid_polygon_mesh(m));
  m.clear();
  hd = CGAL::make_quad(a,b,c,d,m);
  assert(CGAL::is_isolated_quad(hd,m));
  assert(CGAL::is_valid_polygon_mesh(m));
  assert(CGAL::is_quad_mesh(m));
  m.clear();
  hd = CGAL::make_tetrahedron(a,b,c,d,m);
  assert(CGAL::is_tetrahedron(hd,m));
  assert(CGAL::is_triangle_mesh(m));
  assert(CGAL::is_valid_polygon_mesh(m));
  m.clear();
  hd = CGAL::make_hexahedron(a,b,c,d,dd,aa,bb,cc,m);
  assert(CGAL::is_hexahedron(hd,m));
  assert(CGAL::is_quad_mesh(m));
  assert(CGAL::is_valid_polygon_mesh(m));
  m.clear();
  CGAL::make_icosahedron<Mesh, Point_3>(m);
  assert(num_faces(m) == 20);
  assert(CGAL::is_triangle_mesh(m));
  assert(CGAL::is_valid_polygon_mesh(m));
  m.clear();
  hd = CGAL::make_pyramid<Mesh, Point_3>(3, m);
  assert(num_faces(m) == 6);
  assert(CGAL::is_triangle_mesh(m));
  assert(CGAL::is_valid_polygon_mesh(m));
  m.clear();
  hd = CGAL::make_regular_prism<Mesh, Point_3>(4, m);
  assert(num_faces(m) == 16);
  assert(CGAL::is_triangle_mesh(m));
  assert(CGAL::is_valid_polygon_mesh(m));
  m.clear();
  CGAL::make_grid(3,3,m);
  assert(num_faces(m) == 9);
  assert(CGAL::is_quad_mesh(m));
  assert(CGAL::is_valid_polygon_mesh(m));
  std::cerr << "done" << std::endl;
  return 0;
}
Пример #27
0
/*!
 * \brief LAArmadillo::det
 * Calculate the determinant of a
 * \param result
 * \param a
 */
void LAArmadillo::det(double &result, const OiMat &a){
    int matSize = a.getRowCount();
    arma::mat aa(matSize, matSize);

    this->oiMat2Arma(aa, a);

    result = arma::det(aa);
}
Пример #28
0
void gplus(){
  Global++;
  INTERLEV_ACCESS(0,"cs2.gplus","0");  
  INTERLEV_ACCESS(0,"cs3.gplus","0,1");  
  INTERLEV_ACCESS(0,"cs4.gplus","0");  
  INTERLEV_ACCESS(1,"cs1.foo2,cs6.gplus","0,1");  
cs7:  aa();
}
Пример #29
0
 Math::Vector3<T> getVector (int i) {
   switch (i) {
   case 0: return Math::Vector3<T> (aa (), ab (), ac ());
   case 1: return Math::Vector3<T> (ab (), bb (), bc ());
   case 2: return Math::Vector3<T> (ac (), bc (), cc ());
   default: ABORT ();
   }
 }
Пример #30
0
void
sfsserver_auth::userauth::finish ()
{
  assert (!aborted);
  auto_auth aa (authuint_create (authno));
  authno = 0;
  sp->authnos.insert (aid, aa);
  sp->authpending.remove (aid);
}