Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Does Java have a built-in Vector class suitable for handling collision detection / response? It should have methods like subtract(Vector v), normalize(), dotProduct(Vector v), ...

It seems logical to use java.awt.Rectangle and java.awt.Polygon to calculate collisions. Would I be right to use these classes for this purpose?

I understand collision detection; I'm only wondering what approach to it is idiomatic in Java. I'm new to the language and to application development in general.

share|improve this question
Just implement it yourself... That way you can only have methods that you need :) –  Savlon Jun 4 '14 at 10:39

3 Answers 3

up vote 4 down vote accepted

There is no built in math Vector class. You'll have to implement your own or use a library like JScience - its project page is here.

share|improve this answer

You could implement Vectors in Java using Vecmath. Its documentation is located here.

share|improve this answer

There is also a Vector3D class in Apache Commons Math.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.