예제 #1
0
void Vector3f::Rotate(Vector3f axis)
{
	Vector3f currVec = (*this);
	Vector3f axisNorm = axis.GetNorm();
	/*std::cout << "axisNorm: \n";
	axisNorm.Print();
	std::cout << "\n";*/
	Vector3f vecAxisProj = ((*this) * axisNorm) * axisNorm;
	/*std::cout << "vecAxisProj: \n";
	vecAxisProj.Print();
	std::cout << "\n";*/
	Vector3f vecDiff = (*this) - vecAxisProj;
	/*std::cout << "DOT(AXISPROJ , VECDIFF) = " << vecDiff * vecAxisProj << std::endl;*/
	float vecDiffLen = vecDiff.Length();
	/*std::cout << "vecDiff: \n";
	vecDiff.Print();
	std::cout << "\n";*/
	Vector3f vecDiffPerpendicular = (axis ^ vecDiff);
	/*std::cout << "vecDiffPerpendicular: \n";
	vecDiffPerpendicular.Print();
	std::cout << "\n";*/
	Vector3f newVecDiff = (vecDiff.GetNorm() * cosf(axis.Length()) - vecDiffPerpendicular.GetNorm() * sinf(axis.Length())).GetNorm() * vecDiffLen;
	/*std::cout << "newVecDiff: \n";
	newVecDiff.Print();
	std::cout << "\n";
	std::cout << "res: \n";
	(vecAxisProj + newVecDiff).GetNorm().Print();*/
	
	(*this) =  (vecAxisProj + newVecDiff);
}
예제 #2
0
float Vector3f::GetAng(Vector3f v2)
{
	if ((*this).GetNorm() * v2.GetNorm() > 1.0f)
	{
		std::cout << "WARNING\n";	//LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL!!!!!!!!!!!!!!!!!!
		return acosf(floorf((*this).GetNorm() * v2.GetNorm()));
	}
	return acosf((*this).GetNorm() * v2.GetNorm());
}
예제 #3
0
void Explosion::Update(float dt) {
    this->elapsedLifetime -= dt;
    if (this->elapsedLifetime < 0.0f) {
        this->exists = false;
        std::cout << "КОНЕЦ ВЗРЫВА!\n";
    }

    // Обработка взрыва
    //float currRadius = ((totalLifetime - elapsedLifetime) / totalLifetime) * this->maxRadius;

    for (int i = 0; i < owner->GetParticleSystem()->GetParticlesCount(); i++) {
        ParticleHandle<ParticleInfo> blockParticle = owner->GetParticleSystem()->GetParticle(size_t(i));

        Vector3f distance = blockParticle.GetPos() - this->pos;
        //if (distance.Length() <= currRadius) {
        //this->force = desc.force;
        //float force = 1.0f;
        float a = distance.Length();
        float offset = force / (a * a * a);
        Vector3f resultAcceleration = blockParticle.GetAcceleration() + offset * distance.GetNorm();
        blockParticle.SetAcceleration(resultAcceleration);
        //}
    }
}