I've been using Slick for a little while now, I've managed to make some games and all and I was wondering how to use the Vector2f class. I've never really used it, but I've seen many people using it and talking about it and I was wondering how it could be used for my games.
This might sound like a stupid question, but I've never really understood how to use them. So, to understand it more I've looked at the source code but I think I still don't totally get it.
For instance, in most of my games, my Player class would have something like that as attributes to determine his position :
float x, y;
float vx, vy;
vx and vy being the velocity.
Now if I look the vector class I can see it acts like a point (it just has x and y attributes) as well as some methods, in particular add(Vector2f v).
So if I understand well, I'd be able to replace my previous attributes with something like :
So far, ok, it looks interesting.
However it provides many methods I don't understand. For example lengthSquared(), which returns
(x * x) + (y * y);
What is the use of this ? It could be used to see how far the object is from the origin but I don't know why I would want to do this
Another example, there is getTheta(), which returns something I don't understand.
Same for scale, if a Vector2f is something like a Point, I don't understand how it's possible to scale it since it's a like a dot ?
From what I've seen it's like a Vector that starts from 0, 0 to x, y, but I don't see why..
So I think I don't 100% understand how to use correctly this class.
Sorry if that question looks stupid but I'm curious. Am I wrong about the Vector2f class ? Is it just some sort of Point class with methods to "add" them or does it have another use ?