Exemplo n.º 1
0
Point2F Mover::CalculateDrag(float dragMag)
{
	//F drag=-v*v*dragMag
	Point2F drag = -mVelocity;
	drag.Normalize();

	drag *= dragMag;
	drag *= mVelocity.LengthSquared();
	return drag;
}
Exemplo n.º 2
0
Point2F Mover::CalculateAttract(const Mover& other, float g, float minDistanceSquared/*=1.f*/)
{
	//F=G*m1*m2/(r*r)
	Point2F force = mPosition - other.mPosition;
	float distanceSquared =Math::Max(force.LengthSquared(),minDistanceSquared);

	force.Normalize();
	force *= g*mMass*other.mMass;
	force /= distanceSquared;
	return force;
}
Exemplo n.º 3
0
Point2F Mover::CalculateFriction(float frictionMag, const Point2F& gravity)
{
	//Friction=-frictionMag*N*v
	//v==mVelocity.Normalize()

	Point2F friction = -mVelocity;
	friction.Normalize();

	friction *= frictionMag;
	friction *= mMass*gravity;
	return friction;
}