Esempio n. 1
0
void CSpark::EulerStep(float deltaT)
{
	this->deltaT = deltaT;
	ComputeForce();
	FindDeriv();
	UpdateState();
}
Esempio n. 2
0
void TestMoXie::testForceConversion()
{
	Trial trialC3D;
	try
	{
		// load AMTI force data
		auto_ptr<TreeValue> fileC3D( handler.Read("Open3DMotionTest/Data/C3D/sample10/TYPE-4.C3D") );

		// parse
		trialC3D.FromTree( fileC3D.get() );

		// re-write as MoXie
		auto_ptr<TreeValue> moxie_options( FileFormatOptionsMoXie().ToTree() );
		handler.Write("Open3DMotionTest/Data/Temp/rewrite_sample10_TYPE-4.mox", fileC3D.get(), moxie_options.get());
	}
	catch(const MotionFileException& error)
	{
		CPPUNIT_FAIL(error.message);
	}

	// re-load
	Trial trialMox;
	try
	{
		auto_ptr<TreeValue> treeMox( handler.Read("Open3DMotionTest/Data/Temp/rewrite_sample10_TYPE-4.mox") );
		trialMox.FromTree( treeMox.get() );
	}
	catch(const MotionFileException& error)
	{
		CPPUNIT_FAIL(error.message);
	}

	// should be one forceplate in original and in reload
	CPPUNIT_ASSERT_EQUAL(size_t(1), trialC3D.Acq.ForcePlates.NumElements());
	CPPUNIT_ASSERT_EQUAL(size_t(1), trialMox.Acq.ForcePlates.NumElements());

	// expect the six force channels in reload
	CPPUNIT_ASSERT_EQUAL(size_t(6), trialMox.Acq.TimeSequences.NumElements());

	// compute force in each case
	TimeSequence* forceC3D(NULL), *pointC3D(NULL);
	TimeSequence* forceMox(NULL), *pointMox(NULL);
	ComputeForce(forceC3D, pointC3D, trialC3D);
	ComputeForce(forceMox, pointMox, trialMox);

	// all rates should match
	CPPUNIT_ASSERT_DOUBLES_EQUAL(forceC3D->Rate, pointC3D->Rate, 1E-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(forceC3D->Rate, forceMox->Rate, 1E-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(forceC3D->Rate, pointMox->Rate, 1E-6);
	
	// all frame counts should match
	size_t numframes = forceC3D->NumFrames();
	CPPUNIT_ASSERT_EQUAL(numframes, pointC3D->NumFrames());
	CPPUNIT_ASSERT_EQUAL(numframes, forceMox->NumFrames());
	CPPUNIT_ASSERT_EQUAL(numframes, pointMox->NumFrames());

	// thresholder for Fz
	TSVector3ConstIter thresholdFz(*forceC3D);

	// compare numbers - MoXie uses 2 d.p. for N and 2 d.p. for Nm (=> tens column for Nmm)
	CompareTS(*forceC3D, *forceMox, "force", 0.01);
	CompareTS(*pointC3D, *pointMox, "point", 10.0, &thresholdFz);
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
  vect zero;
  vectSetZero(zero);
  float a = vectGetLength(zero);
  printf("%f\n", abs((int)(a)));
  if (abs(a) > 0.0f) printf("aaa\n");
	char *strFileName = (char*) malloc(sizeof(char)*1024);
	
	Demon d1;
	//InitDemon2Gran(&d1);
  vect or;
  vectSetValue(or, 1.0, 1.0, 1.0);

	//InitDemonBox(&d1, or, 4, 4, 4);
	//InitDemonGroGra(&d1);

	pov pov1;
  pov1.num_light = 0;
  pov1.num_include= 0;
	//vectSetValue(&(pov1.camera.location), 10, 10, 10);
	//vectSetValue(&(pov1.camera.lookAt), 0, 0, 0);
	vectSetValue(&(pov1.camera.location), 0, 15, 5);
	vectSetValue(&(pov1.camera.lookAt), 0, 0, 0);

	pov_light light1;
	vectSetValue(&(light1.location), 20, 0, 20);
	lightSetColor(&light1, "White");
	povAddLight(&pov1, &light1);
	vectSetValue(&(light1.location), -20, 0, 20);
	lightSetColor(&light1, "White");
	povAddLight(&pov1, &light1);
	vectSetValue(&(light1.location), 0, -20, 20);
	lightSetColor(&light1, "White");
	povAddLight(&pov1, &light1);
	vectSetValue(&(light1.location), 0, 20, 20);
	lightSetColor(&light1, "White");
	povAddLight(&pov1, &light1);
	povAddInclude(&pov1, "colors");

  unsigned iCurDemon = INIT_GRAN_ONE_NOR;
  //for(iCurDemon = 0; iCurDemon < INIT_FUNC_NUM; iCurDemon ++) 
  {
    (initList[iCurDemon])(&d1);

    pov1.dem_scene = &d1;
    unsigned output_rate = (unsigned)(1.0/25.0/d1.time_step);
    char cmd[256];
    sprintf(cmd, "mkdir out/%s", filenameList[iCurDemon]);
    system(cmd);
    sprintf(cmd, "mkdir out/%s/pov", filenameList[iCurDemon]);
    system(cmd);
    sprintf(cmd, "rm out/%s/pov/*.pov", filenameList[iCurDemon]);
    system(cmd);
    for (unsigned iFrame = 0; iFrame < 9000; iFrame ++) {
      //printf("%u\n", iFrame);
      if (iFrame % output_rate == 0) {
        //sprintf(strFileName, "/home/hammurabi/toShare/demon-1/pov/GroundGranular%03u.pov", iFrame/output_rate);
        sprintf(strFileName, "out/%s/pov/%03u.pov", filenameList[iCurDemon], iFrame/output_rate);
        //printf("%f\t%f\t%f\n", d1.sand[0].component[0].position[0], d1.sand[0].component[0].position[1], d1.sand[0].component[0].position[2]);
        if( 0 == povSave(&pov1, strFileName)) {
          printf("Can't open file: %s\n", strFileName);
          return -1;
        }
      }
      printf("%04u:", iFrame);
      GranularPrint(d1.sand);
      ComputeForce(&d1);
      TimeIntergration(&d1);
    }
    FreeDemon(&d1);
  }
  free(strFileName);
	povFree(&pov1);
  return 0;
}