# Obtaining Vectors

There are different ways to obtain a vector.

First is by using the [toVector](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Location.html#toVector\(\)) method on a location. This will use the coordinates from that location and form a vector with the values. Second is the [getDirection](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Location.html#getDirection\(\)) method on a location as well. This one is a bit more abstract because not every location always has a meaningful direction. For example the location of a block in a world doesn't have any direction. Instead locations obtained from entities (like players) contain information where the player is looking at. A direction vector will always be a unit-vector.

{% hint style="info" %}
A unit-vector is a vector with a length of 1. Any vector can become a unit-vector by normalizing it. Unit-Vectors are special when used in context with other operations like for example the dot product.
{% endhint %}

![purple = toVector on player location
orange = getDirection on player location](https://3012238209-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3CiKZGX91xk3wTXNDkac%2Fuploads%2FceG9xJ63m5Oq1gZyFTL8%2F2022-03-09_21.11.28.png?alt=media\&token=5249c137-4c1a-4af9-8fe2-61518e8f05c8)

{% hint style="warning" %}
Please note that this is purely for a visual sake. As explained on the previous page, the orange direction vector actually sits at the origin.

Also note that the point where the 3 axes meet is not actually the origin in the world. It's an artifical origin to illustrate the point.
{% endhint %}

Third is [creating vectors](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/util/Vector.html#%3Cinit%3E\(double,double,double\)) yourself. Sometimes you need to create vectors yourself as well.

{% hint style="warning" %}
You can also obtain a vector through the [getVelocity](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Entity.html#getVelocity\(\)) method. In the context of this tutorial this is **not** what you want.
{% endhint %}
