Example #1
0
int CurieIMUClass::readAccelerometer(int axis)
{
    if (axis == X_AXIS) {
        return getAccelerationX();
    } else if (axis == Y_AXIS) {
        return getAccelerationY();
    } else if (axis == Z_AXIS) {
        return getAccelerationZ();
    }

    return 0; 
}
Example #2
0
	void ParticleSystem::render(float dt)
	{
		preRender(dt);

		unsigned int newParticles = 0;
		if (mParticleList.size() < static_cast<unsigned int>(mMaxParticles))
		{
			mCurrentParticleCount += dt * mParticlesPerSecond;
			newParticles = static_cast<unsigned int>(mCurrentParticleCount);
			if (mParticleList.size() + newParticles > static_cast<unsigned int>(mMaxParticles)) 
			{
				newParticles = mMaxParticles - mParticleList.size();
			}
			mCurrentParticleCount -= static_cast<float>(newParticles);
		}
		else
		{
			mCurrentParticleCount = 0.0f;
		}

		if (newParticles > 0)
		{
			for (unsigned int i = 0; i < newParticles; i++)
			{
				newParticle();
			}
		}

		float accX = getAccelerationX() * dt;
		float accY = getAccelerationY() * dt;
		float ageResp = 1.0f / mMaxAge;
		float alphaRange = mEndAlpha - mStartAlpha;
		for (size_t i = 0; i < mParticleList.size(); i++)
		{
			Particle *particle = mParticleList[i];

			float t = particle->getAge() * ageResp;
			particle->getGfxComponent()->setAlpha(t * alphaRange + mStartAlpha);
			particle->preRender(*this, accX, accY, dt);
			if (particle->getAge() >= mMaxAge)
			{
				particle->postRender(dt);
				mParticleList.erase(mParticleList.begin() + i);
				i--;
				continue;
			}
			particle->render(dt);
			particle->postRender(dt);
		}

		postRender(dt);
	}
Example #3
0
float CurieImuClass::readAccelerometerScaled(int axis)
{
    int16_t raw;

    if (axis == X_AXIS) {
        raw = getAccelerationX();
    } else if (axis == Y_AXIS) {
        raw = getAccelerationY();
    } else if (axis == Z_AXIS) {
        raw = getAccelerationZ();
    } else {
        return 0;
    }

    return convertRaw(raw, accel_range);
}
double BoschBMA250::getVectorMagnitude()
{
    double magnitude = sqrt(square(getAccelerationX()) + square(getAccelerationY()) + square(getAccelerationZ()));
    return magnitude;
}