-
Notifications
You must be signed in to change notification settings - Fork 13
Lua:Vector2D
This is useful for doing Math on 2D vectors of X & Y. One of the more helpful aspects is that you can do math on them as if they were numbers, for example:
a = Vector2D.From(2,3)
b = Vector2D.From(1,4)
c = a + b -- c ends up being equal to (3,7)note x/y are readonly because of weird internal technical reasons. (thinking out loud: should I change them to .GetX() / .GetY() for that reason?) if you want to change them, see .WithX() / .WithY()
see the wikipedia article on manhattan distance
returns a new vector with a given X and the original Y. so if you want to change some_vector's x to 5, you can do
some_vector = some_vector.WithX(5)
for example
see the wikipedia article on manhattan distance
IsFinite() returns false if either coordinate is positive/negative infinity or NaN. If you try to use move vertices or things to non-finite positions, you will get a script error, so it may be useful to check that this returns true on your Vector2Ds if you are doing division or checking for line intersections.