Quick Way to Get Vector Distance?
by John Kanalakis · in Torque X 2D · 10/21/2007 (6:04 pm) · 1 replies
Is there a quick way to get the distance between to vector points? TGB has t2dVectorDistance and it seems like the T2DVectorUtil class would be a great place stick this. I'm able to get by with my own Pythagorian check for now, but I'm wondering if there's a faster way. Currently, I'm calculating this...
by coding this...
John K.
by coding this...
float xDist = System.Math.Abs(_sceneObject.Position.X - _targetObject.Position.X); float yDist = System.Math.Abs(_sceneObject.Position.Y - _targetObject.Position.Y); double Distance = System.Math.Sqrt((xDist * xDist) + (yDist * yDist));
John K.
About the author
John Kanalakis is the owner of EnvyGames, an independent game development studio in Silicon Valley that produces games and tools for Xbox 360, Windows, and the Web.
Associate John Kanalakis
EnvyGames
John K.