-
Notifications
You must be signed in to change notification settings - Fork 0
Vector2
Jesusemora edited this page Mar 30, 2023
·
3 revisions
| Variable | Description |
|---|---|
float &x |
reference to the first element of pos[]. can be used as myVector2.x. |
float &y |
reference to the second element of pos[]. can be used as myVector2.y. |
| Function | Description |
|---|---|
float Magnitude() |
returns non sqr magnitude of current Vector2
|
float sqrMagnitude() |
returns sqr magnitude of current Vector2
|
void Normalize() |
normalizes current Vector2
|
Vector2 normalized |
returns the normalized version of current Vector2
|
| Variable | x | y |
|---|---|---|
Vector2 up |
0 | 1 |
Vector2 down |
0 | -1 |
Vector2 left |
-1 | 0 |
Vector2 right |
1 | 0 |
Vector2 zero |
0 | 0 |
use these to quickly obtain a "vector" in a given direction, or a Vector2 filled with 0
| Function | Description |
|---|---|
float fastDistance(Vector2 a, Vector2 b) |
returns the distance between a and b in a tiled space ( like chess ) |
float Distance(Vector2 a, Vector2 b) |
returns the exact distance between a and b |
float Dot(Vector2 a, Vector2 b) |
returns the dot product of a and b |
Vector2 Lerp(Vector2 a, Vector2 b) |
returns the middle point between a and b, equivalent to glsl mix(a, b, 0.5) or cg lerp(a, b, 0.5)
|
Vector2 Lerp(Vector2 a, Vector2 b, float c) |
returns the point c between a and b, equivalent to glsl mix(a, b, c) or cg lerp(a, b, c)
|
Vector2 Slerp(Vector2 a, Vector2 b, float c) |
smooth interpolation between a and b given c. |
Vector2(float x, float y) |
generates a Vector2 containing the values x and y. |
Vector2() |
generates a Vector2 containing the values 0 and 0. |
operator+ adds two Vector2s
operator- substracts two Vector2s
operator+= adds the values of Vector2 to current
operator-= substracts the values of Vector2 from current
operator* multiplies current Vector2 by a float
operator/ divides current Vector2 by a float
operator+ adds float to every value of current Vector2
operator- substracts float from every value of current Vector2
operator*= multiplies every value of current Vector2 by float
operator/= divides every value of current Vector2 by float
operator== returns true if two Vector2s are equal and false if they are different