|
Binding of Isaac - Afterbirth+ Lua Reference/Guide
|
Public Member Functions | |
| Vector (float, float) | |
| Normalize () | |
| Vector | Normalized () |
| float | Dot (Vector second) |
| float | Cross (Vector second) |
| Vector | Lerp (Vector first, Vector second, float t) * |
| float | Distance (Vector first, Vector second) |
| float | DistanceSquared (Vector first, Vector second) |
| Vector | Rotated (float AngleDegrees) |
| float | GetAngleDegrees () |
| Resize (float NewLength) | |
| Vector | Resized (float NewLength) |
| Clamp (float MinX, float MinY, float MaxX, float MaxY) | |
| Vector | Clamped (float MinX, float MinY, float MaxX, float MaxY) |
| float | Length () |
| float | LengthSquared () |
| Vector | __add (Vector Right) |
| Vector | __sub (Vector Right) |
| Vector | __mul (float Modifier) |
| Vector | __div (float Modifier) |
| Vector | __unm (Vector Right) |
Static Public Member Functions | |
| static Vector | FromAngle (float AngleDegrees) |
Public Attributes | |
| float | X |
| Components of vector. More... | |
| float | Y |
| Vector::Vector | ( | float | , |
| float | |||
| ) |
| Vector Vector::__div | ( | float | Modifier | ) |
Division operators
| Vector Vector::__mul | ( | float | Modifier | ) |
Multiplication operators
| Vector::Clamp | ( | float | MinX, |
| float | MinY, | ||
| float | MaxX, | ||
| float | MaxY | ||
| ) |
Clamps the vector based on left, top, right, bottom boundings. Doesn't keep direction
| Vector Vector::Clamped | ( | float | MinX, |
| float | MinY, | ||
| float | MaxX, | ||
| float | MaxY | ||
| ) |
Returns a clamped version of the vector.
| float Vector::Cross | ( | Vector | second | ) |
Cross product this is the 2x2 matrix determinant or the resulting z value for their 3D versions with z=0
Returns distance between two vectors
local sqtDist = Vector(2,0):Distance(Vector(4,0))) --sqtDist = 2
Returns squared distance between two vectors
local sqtDist = Vector(2,0):DistanceSquared(Vector(4,0))) --sqtDist = 4
| float Vector::Dot | ( | Vector | second | ) |
Dot product
|
static |
Build a Vector from an angle, returns a normalized vector. Angle 0 will result in (1, 0). Angle 90 will result in (0, 1).
local vec = Vector.FromAngle(45)) --vec is now Vector(0.70711,0.70711)
| float Vector::GetAngleDegrees | ( | ) |
Returns the angle the vector is facing. The vector (1, 0) will be at 0 degrees. The vector (0, 1) will be at 90 degrees.
local v1 = Vector(1,0) -- has angle 0.0
local v2 = Vector(0,1) -- has angle 90.0
local v3 = v2-v1 -- subtraction of 2 points is a vector connecting the two points
print(v3:GetAngleDegrees()) -- prints 45.0
| float Vector::Length | ( | ) |
Returns the length of the vector
| float Vector::LengthSquared | ( | ) |
Returns the length squared of the vector
Linear interpolation between two vectors. For t = 0 it returns the first Vector, for t = 1 it returns the second.
local v1 = Vector(0,0)
local v2 = Vector(1,1)
v1:Lerp(v2,0.5) -- v1 equals Vector(0.5,0.5) now
function Lerp(vec1, vec2, percent)
return vec1 * (1 - percent) + vec2 * percent
end
| Vector::Normalize | ( | ) |
Normalizes this vector
| Vector Vector::Normalized | ( | ) |
Returns a normalized version of this vector
| Vector::Resize | ( | float | NewLength | ) |
Resizes the vector length.
| Vector Vector::Resized | ( | float | NewLength | ) |
Returns a resized version of the vector.
| Vector Vector::Rotated | ( | float | AngleDegrees | ) |
Returns a rotated version of the vector by AngleDegrees
| float Vector::X |
Components of vector.
| float Vector::Y |