0

I am looking for a Java library or package that I can use to work with 2D vectors of the direction & magnitude variety, and can easily convert between Cartesian coordinates (x, y) and polar (angle & distance; aka direction & magnitude).

Specifically, I need to be able to add, subtract, and multiply vectors. I need to be able to take an x and y coordinate and get the angle and distance from the origin (0,0).

The specific use will be in a physics game, used to deal with elastic and inelastic collisions. I'm confident that code has already been written to do these things, but I am unsure what to google to find what I need. If all else fails, I could try to write it myself, but I'd rather use something that's already been written. If there is a game library that includes this sort of physics functionality, that might be even better.

4

1 回答 1

1

检查libGDX。您不需要使用它,但您可以查看他们的Vector2实现并在获得它后派生出您自己的实现。libGDX 的源代码是开放的。

于 2013-08-22T16:29:44.800 回答