"2D Vector" Module

BlitzMax Forums/BlitzMax Programming/"2D Vector" Module

Mauft(Posted 2008) [#1]
Ok, to be honest I wasn't sure where to put this, so I think this is the least wrong category, so anyway - here we go:

Hi there folks!
As you might guess I'm a newbie here, but don't get too hasty, as I am not a noob in Blitzmax :). Truth be told I've been poking around it for over a year, and at some point I got myself into making few modules, and now I want to present it to you - 2D Vector module.

Basically this little fella gives you the ability to work with 2D vectors quickly and easily. Specially designed Vector objects have most of the functions you will need (if not every). A little list:
-Every vector can be increased, decreased, multiplied and divided both by vector and independent numbers.
-Calculate Length and Angle
-Calculate the smaller angle between two vectors - one function retaining the sign, one being Absolute value
-Create normalized vectors (vectors of length 1)
-Quick and easy creation of clones of vectors
-Calculating the dot product of two vectors
-Rotating a vector by an angle

Also worth mentioning is that, just like in those built-in modules, every function can be accessed both through reference to existing instance "vector.function()" or by using a function "vectorAdd()" which add ability to work on and return vector clone instead.

Two examples might too be useful for better understanding the module.
You can download the module from here:
http://www.fileden.com/files/2007/10/7/1489821/Mauft-Vector.zip
http://retrocade.net/post/138/blitzmax-vector-library

For other modules made by me I can suggest my site:
http://mauft.com/blitzmax

(hopefully) Enjoy!

Last edited 2013


Grey Alien(Posted 2008) [#2]
Welcome and thanks for the modules! :-)


Warpy(Posted 2008) [#3]
I've written vector objects a few times in the past, and I'm not sure they're worth the bother while we can't override the operators in BMax, to allow for example vec3=vec1+vec2.

Looks like a nicely written module anyway, and well documented!


Mauft(Posted 2008) [#4]
I can assure you they are worthy, albeit they indeed happen to be a bit uncomfortable. But lately I was working on an Arkanoid/BreakOut engine with realistic bounce angles, and vectors were a true lifesaver - they are both more straightforward to use that two separate variables for position, speed, other speed, other something etc. And that most C++ developers, which helped me in coding, were using vectors.

But yeah, ability to make addition Operators, just like in C++, would be splendid. I wish they would add it sooner or later.


slenkar(Posted 2008) [#5]
im using it to calculate angles between 2 points thanks


Mauft(Posted 2013) [#6]
It has been quite a few years, but I've seen around the forums that people are still in need of this module, so...

I've took my time to update the module, clean it up a little bit and once again officially make it available. The info page is available here:

http://retrocade.net/post/138/blitzmax-vector-library

And the direct link to currently latest version:

http://cdn.retrocade.net/uploads/files/libraries/BlitzmaxVector_1.40.zip


Cruis.In(Posted 2013) [#7]
do we need mingw for this? i could of used something like this before I learned more about vectors, but I am sure it will still come in handy! Since it beats doing calculations myself!


Mauft(Posted 2013) [#8]
Nope, there are no external libraries used, it should work out of the box... I think. I haven't used BlitzMax for a couple of years :).


Cruis.In(Posted 2013) [#9]
shame on you :)