Game Development Community

FxSceneObject2D::getPolarVelocity()

by John Vanderbeck · in Torque Game Builder · 04/01/2005 (6:49 am) · 4 replies

Just a suggestion. I think it would be a useful function. I know I could use it :p

Maybe someoen smarter than me in math just wrote thier own function but since T2D is all about making things easy, this seemed to be a good suggestion.

#1
04/01/2005 (7:05 am)
Wouldn't that be the same as getLinearVelocity() + getRotation()?
#2
04/01/2005 (8:44 am)
There is a new "getLinearVelocityPolar()" function in the coming update. :)

- Melv.
#3
04/01/2005 (9:19 am)
@Phillip
I don't think so.

@Melv
Whee :)
#4
04/01/2005 (9:21 am)
To save you waiting, add to "fxSceneObject2D.cc"...

//-----------------------------------------------------------------------------
// Get Linear Velocity Polar.
//-----------------------------------------------------------------------------
ConsoleMethod(fxSceneObject2D, getLinearVelocityPolar, const char*, 2, 2, "Gets Objects Linear Velocity using Polar angle/speed.")
{
	// Get Linear Velocity.
	fxVector2D linearVelocity = object->getLinearVelocity();

	// Create Returnable Buffer.
	char* pBuffer = Con::getReturnBuffer(256);
	// Format Buffer.
	dSprintf(pBuffer, 256, "%f %f", mRadToDeg(mAtan(linearVelocity.mX, -linearVelocity.mY)), linearVelocity.len() );
	// Return Velocity.
	return pBuffer;

}

- Melv.