Esempio n. 1
0
void TestVector()
{
	Vector<int> v1;
	v1.PushBack(1);
	v1.PushBack(2);
	v1.PushBack(3);
	v1.PushBack(4);
	v1.PushBack(5);
	v1.PushBack(6);
	v1.PushBack(7);
	v1.PushBack(8);

	PrintVector1(v1);

	// 迭代器失效
	Vector<int>::Iterator it = v1.Begin();
	while(it != v1.End())
	{
		if (*it % 2 == 0)
			it = v1.Erase(it);
		else
			++it;
	}

	PrintVector1(v1);
	PrintVector2(v1);
	PrintVector3(v1);
}
Esempio n. 2
0
//testing accelerometer readings. To enable the test, search below for "ACCELTEST"
//Note: You'll need to look at the  debug log to see the output. (For android, run PhoneLog.bat from RTBareBones/android)
void App::OnAccel(VariantList *pVList)
{
	
	if ( int(pVList->m_variant[0].GetFloat()) != MESSAGE_TYPE_GUI_ACCELEROMETER) return;

	CL_Vec3f v = pVList->m_variant[1].GetVector3();

	LogMsg("Accel: %s", PrintVector3(v).c_str());

	v.x = v.x * kFilteringFactor + v.x * (1.0f - kFilteringFactor);
	v.y = v.y * kFilteringFactor + v.y * (1.0f - kFilteringFactor);
	v.z = v.z * kFilteringFactor + v.z * (1.0f - kFilteringFactor);

	// Compute values for the three axes of the acceleromater
	float x = v.x - v.x;
	float y = v.y - v.x;
	float z = v.z - v.x;

	//Compute the intensity of the current acceleration 
	if (sqrt(x * x + y * y + z * z) > 2.0f)
	{
		Entity *pEnt = GetEntityRoot()->GetEntityByName("jumble");
		if (pEnt)
		{
			//GetAudioManager()->Play("audio/click.wav");
            VariantList vList(CL_Vec2f(), pEnt);
			pEnt->GetFunction("OnButtonSelected")->sig_function(&vList);
		}
		LogMsg("Shake!");
	}
}
int main()
{
  // all matrices are 3x3, stored row-major
  // random matrix for M (for testing)
  double M[9] = {-0.2807952341472597, 0.3115011511885256, -0.0485903249146864, 
                 -0.45015464324442633, -0.8543680801174494, 0.19492773318804713, 
                  0.36840026899411693, 0.8634092118662448, 0.7528384426032098};     

  double Q[9]; // output
  double S[9]; // output
  double tol = 1e-12;
  PolarDecomposition::Compute(M, Q, S, tol); 

  PrintMatrix3x3(Q, "Q");
  PrintMatrix3x3(S, "S");

  // random matrix for MDot (for testing)
  double MDot[9] = {0.5118439624450675, 0.24235217728059955, -0.7450654689862747, 
                    -0.4345942647112335, 1.6156424648429977, -0.6830032318171733, 
		    -0.44285129704233783, -0.4366569686333789, -1.0401543827923478};

  // random matrix for MDotDot (for testing)
  double MDotDot[9] = {-0.12353971625289528, -0.14236178366865948, 0.7566400471581742, 
                       1.8378313423900419, 0.1496418600146152, 0.351961331124921, 
		       0.42477528592658276, 0.6794947974490568, 1.3110637123590698};

  double omega[3]; // output
  double QDot[9]; // output
  double SDot[9]; // output
  double omegaDot[3]; // output
  double QDotDot[9]; // output
  PolarDecompositionGradient::Compute(M, Q, S, MDot, omega, QDot, SDot, MDotDot, omegaDot, QDotDot);

  PrintVector3(omega, "omega");
  PrintMatrix3x3(QDot, "QDot");
  PrintMatrix3x3(SDot, "SDot");
  PrintVector3(omegaDot, "omegaDot");
  PrintMatrix3x3(QDotDot, "QDotDot");

  return 0;
}