![]() |
Nano Brain for Unity v0.1
|
2-dimensional vectors
Public Member Functions | |
| Vector2Float (float x, float y) | |
| Create a new 2-dimensional vector. | |
| Vector2Float (Vector2Int v) | |
| Convert a Vector2Int into a Vector2Float. | |
| override readonly bool | Equals (object obj) |
| Tests if the vector is equal to the given object. | |
| override readonly int | GetHashCode () |
| Get an hash code for the vector. | |
Static Public Member Functions | |
| static float | SqrMagnitudeOf (Vector2Float v) |
| static float | MagnitudeOf (Vector2Float v) |
| static Vector2Float | Normalize (Vector2Float v) |
| static Vector2Float | operator+ (Vector2Float v1, Vector2Float v2) |
| Add two vectors. | |
| static Vector2Float | operator- (Vector2Float v1, Vector2Float v2) |
| Subtract two vectors. | |
| static Vector2Float | operator- (Vector2Float v1) |
| Negate the vector. | |
| static Vector2Float | operator/ (Vector2Float v, float f) |
| Scale a vector uniformly down. | |
| static Vector2Float | operator* (Vector2Float v1, float f) |
| Scale a vector uniformly up. | |
| static Vector2Float | operator* (float f, Vector2Float v1) |
| Scale a vector uniformly up. | |
| static Vector2Float | Scale (Vector2Float v1, Vector2Float v2) |
| Scale the vector using another vector. | |
| static bool | operator== (Vector2Float v1, Vector2Float v2) |
| Tests if the vector has equal values as the given vector. | |
| static bool | operator!= (Vector2Float v1, Vector2Float v2) |
| Tests if two vectors have different values. | |
| static float | Distance (Vector2Float v1, Vector2Float v2) |
| Get the distance between two vectors. | |
| static float | Dot (Vector2Float v1, Vector2Float v2) |
| The dot product of two vectors. | |
| static float | SignedAngle (Vector2Float from, Vector2Float to) |
| Calculate the signed angle between two vectors. | |
| static float | UnsignedAngle (Vector2Float from, Vector2Float to) |
| static Vector2Float | Rotate (Vector2Float v1, AngleFloat angle) |
| Rotates the vector with the given angle. | |
| static Vector2Float | Lerp (Vector2Float v1, Vector2Float v2, float f) |
| Lerp between two vectors. | |
| static float | ToFactor (Vector2Float v1, Vector2Float v2) |
| Map interval of angles between vectors [0..Pi] to interval [0..1]. | |
Public Attributes | |
| float | horizontal |
| The right axis of the vector. | |
| float | vertical |
| The upward/forward axis of the vector. | |
Static Public Attributes | |
| static readonly Vector2Float | zero = new Vector2Float(0, 0) |
| A vector with zero for all axis. | |
| static readonly Vector2Float | one = new Vector2Float(1, 1) |
| A vector with values (1, 1) | |
| static readonly Vector2Float | up = new Vector2Float(0, 1) |
| A vector with values (0, 1) | |
| static readonly Vector2Float | down = new Vector2Float(0, -1) |
| A vector with values (0, -1) | |
| static readonly Vector2Float | forward = new Vector2Float(0, 1) |
| A vector with values (0, 1) | |
| static readonly Vector2Float | back = new Vector2Float(0, -1) |
| A vector with values (0, -1) | |
| static readonly Vector2Float | left = new Vector2Float(-1, 0) |
| A vector3 with values (-1, 0) | |
| static readonly Vector2Float | right = new Vector2Float(1, 0) |
| A vector with values (1, 0) | |
Properties | |
| readonly float | sqrMagnitude [get] |
| The squared length of this vector. | |
| readonly float | magnitude [get] |
| The length of this vector. | |
| Vector2Float | normalized [get] |
| Convert the vector to a length of a 1. | |
| LinearAlgebra.Vector2Float.Vector2Float | ( | float | x, |
| float | y | ||
| ) |
Create a new 2-dimensional vector.
| x | x axis value |
| y | y axis value |
| LinearAlgebra.Vector2Float.Vector2Float | ( | Vector2Int | v | ) |
Convert a Vector2Int into a Vector2Float.
| v | The Vector2Int |
|
static |
Add two vectors.
| v1 | The first vector |
| v2 | The second vector |
|
static |
Subtract two vectors.
| v1 | The first vector |
| v2 | The second vector |
|
static |
Negate the vector.
| v1 | The vector to negate |
This will result in a vector pointing in the opposite direction
|
static |
Scale a vector uniformly down.
| v | The vector to scale |
| f | The scaling factor |
Each component of the vector will be devided by the same factor.
|
static |
Scale a vector uniformly up.
| v1 | The vector to scale |
| f | The scaling factor |
Each component of the vector will be multipled with the same factor.
|
static |
Scale a vector uniformly up.
| f | The scaling factor |
| v1 | The vector to scale |
Each component of the vector will be multipled with the same factor.
|
static |
Scale the vector using another vector.
| v1 | The vector to scale |
| v2 | A vector with the scaling factors |
|
static |
Tests if the vector has equal values as the given vector.
| v1 | The vector to compare to |
Tests if the two vectors have equal values
| v1 | The first vector |
| v2 | The second vector |
Note that this uses a Float equality check which cannot be not exact in all cases. In most cases it is better to check if the Vector2.Distance between the vectors is smaller than Float.epsilon Or more efficient: (v1 - v2).sqrMagnitude < Float.sqrEpsilon
|
static |
Tests if two vectors have different values.
| v1 | The first vector |
| v2 | The second vector |
Note that this uses a Float equality check which cannot be not exact in all case. In most cases it is better to check if the Vector2.Distance between the vectors is smaller than Float.epsilon. Or more efficient: (v1 - v2).sqrMagnitude < Float.sqrEpsilon
| override readonly bool LinearAlgebra.Vector2Float.Equals | ( | object | obj | ) |
Tests if the vector is equal to the given object.
| obj | The object to compare to |
| override readonly int LinearAlgebra.Vector2Float.GetHashCode | ( | ) |
Get an hash code for the vector.
|
static |
Get the distance between two vectors.
| v1 | The first vector |
| v2 | The second vector |
|
static |
The dot product of two vectors.
| v1 | The first vector |
| v2 | The second vector |
|
static |
Calculate the signed angle between two vectors.
| from | The starting vector |
| to | The ending vector |
| axis | The axis to rotate around |
|
static |
Rotates the vector with the given angle.
| v1 | The vector to rotate |
| angle | The angle in degrees |
|
static |
Lerp between two vectors.
| v1 | The from vector |
| v2 | The to vector |
| f | The interpolation distance [0..1] |
The factor f is unclamped. Value 0 matches the v1 vector, Value 1 matches the v2 vector Value -1 is v1 vector minus the difference between v1 and v2 etc.
|
static |
Map interval of angles between vectors [0..Pi] to interval [0..1].
| v1 | The first vector |
| v2 | The second vector |
Vectors a and b must be normalized
|
get |
The squared length of this vector.
The squared length is computationally simpler than the real length. Think of Pythagoras A^2 + B^2 = C^2. This leaves out the calculation of the squared root of C.
|
get |
The length of this vector.
|
get |
Convert the vector to a length of a 1.