# Vectors

Discussion in 'Plugin Development' started by Nogtail, Dec 5, 2013.

Not open for further replies.
1. Offline

### Nogtail

From my understanding a vector has a direction as well as a magnitude but for Bukkit and a lot of plugins I have seen Vectors are just used to store a location, so I was wondering why choose the name vector?

#1
2. Offline

### Mathias Eklund

Cause it is vectors.

#2
3. Offline

### Forge_User_95269065

Nogtail
Vector is called vector because that word explains it perfectly.

4. Offline

#4
5. Offline

### blablubbabc

Vector's can also be interpreted as locations in space, because you can always add the vector (interpreted as direction+magnitude) to the origin (the 0,0,0-coordinate), which results in the same result: (0,0,0) + vector = vector

#5
6. Offline

### LucasEmanuel

Vectors are very handy when storing locations, they are also very handy when storing a cuboid region. Instead of storing two bukkit-locations you only need to store one vector for a cubiod

EDIT:
To expand on what I'm talking about:

Let us say we want to store a cuboid region defined by two locations in a world. We could just store both of the locations and be fine with it, or we could half the amount of space required to store it by defining the cuboid as a single vector, meaning, a pointer that starts at the first location we want to store and points to the second location we want to store.

So, by using the calculation I showed in my vector tutorial on how to create a vector that points between two locations we can create this "region" vector like this:

Vector region = second_loc.toVector().subtract(first_loc.toVector());

And then all you have to do is save the x, y, z, and magnitude for the vector and suddenly you have pretty much halved the amount of stuff to save.

EDIT 2:
Forget what I just said, I seem to be very confused right now. Today's lecture on how to calculate time complexity and using the master theorem when working with recursive functions has messed up my brain. Time for coffee.

#6