vec2 library Null safety

Constants

dist → const double Function(List<double> a, List<double> b)
Alias for {@link vec2.distance} @function
distance
div → const List<double> Function(List<double> out, List<double> a, List<double> b)
Alias for {@link vec2.divide} @function
divide
len → const double Function(List<double> a)
Alias for {@link vec2.length} @function
length
mul → const List<double> Function(List<double> out, List<double> a, List<double> b)
Alias for {@link vec2.multiply} @function
multiply
sqrDist → const List<double> Function(dynamic a, dynamic b)
Alias for {@link vec2.squaredDistance} @function
squaredDistance
sqrLen → const List<double> Function(dynamic a)
Alias for {@link vec2.squaredLength} @function
squaredLength
sub → const List<double> Function(List<double> out, List<double> a, List<double> b)
Alias for {@link vec2.subtract} @function
subtract

Properties

forEach List<double> Function(List<double> a, int? stride, int? offset, int? count, dynamic fn, dynamic arg)
Perform some operation over an array of vec2s.
final

Functions

add(List<double> out, List<double> a, List<double> b) List<double>
Adds two vec2's
angle(List<double> a, List<double> b) double
Get the angle between two 2D vectors @param {ReadonlyVec2} a The first operand @param {ReadonlyVec2} b The second operand @returns {Number} The angle in radians
boolequals(dynamic a, dynamic b) → dynamic
Returns whether or not the vectors have approximately the same elements in the same position.
ceil(List<double> out, List<double> a) List<double>
math.ceil the components of a vec2
clone(dynamic a) List<double>
Creates a new vec2 initialized with values from an existing vector
copy(List<double> out, List<double> a) List<double>
Copy the values from one vec2 to another
create() List<double>
Creates a new, empty vec2
cross(dynamic out, dynamic a, dynamic b) List<double>
Computes the cross product of two vec2's Note that the cross product must by definition produce a 3D vector
distance(List<double> a, List<double> b) double
Calculates the euclidian distance between two vec2's
divide(List<double> out, List<double> a, List<double> b) List<double>
Divides two vec2's
dot(dynamic a, dynamic b) List<double>
Calculates the dot product of two vec2's
exactEquals(dynamic a, dynamic b) bool
Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
floor(List<double> out, List<double> a) List<double>
math.floor the components of a vec2
fromValues(double x, double y) List<double>
Creates a new vec2 initialized with the given values
inverse(dynamic out, dynamic a) List<double>
Returns the inverse of the components of a vec2
length(List<double> a) double
Calculates the length of a vec2
lerp(dynamic out, dynamic a, dynamic b, dynamic t) List<double>
Performs a linear interpolation between two vec2's
max(List<double> out, List<double> a, List<double> b) List<double>
Returns the maximum of two vec2's
min(List<double> out, List<double> a, List<double> b) List<double>
Returns the minimum of two vec2's
multiply(List<double> out, List<double> a, List<double> b) List<double>
Multiplies two vec2's
negate(dynamic out, dynamic a) List<double>
Negates the components of a vec2
normalize(dynamic out, dynamic a) List<double>
Normalize a vec2
random(List<double> out, double? scale) List<double>
Generates a random vector with the given scale
rotate(List<double> out, List<double> a, List<double> b, double rad) List<double>
Rotate a 2D vector @param {vec2} out The receiving vec2 @param {ReadonlyVec2} a The vec2 point to rotate @param {ReadonlyVec2} b The origin of the rotation @param {Number} rad The angle of rotation in radians @returns {vec2} out
round(List<double> out, List<double> a) List<double>
math.round the components of a vec2
scale(List<double> out, List<double> a, double b) List<double>
Scales a vec2 by a scalar number
scaleAndAdd(List<double> out, List<double> a, List<double> b, double scale) List<double>
Adds two vec2's after scaling the second operand by a scalar value
set(List<double> out, double x, double y) List<double>
Set the components of a vec2 to the given values
squaredDistance(dynamic a, dynamic b) List<double>
Calculates the squared euclidian distance between two vec2's
squaredLength(dynamic a) List<double>
Calculates the squared length of a vec2
str(dynamic a) String
Returns a string representation of a vector
subtract(List<double> out, List<double> a, List<double> b) List<double>
Subtracts vector b from vector a
transformMat2(List<double> out, List<double> a, List<double> m) List<double>
Transforms the vec2 with a mat2
transformMat2d(List<double> out, List<double> a, List<double> m) List<double>
Transforms the vec2 with a mat2d
transformMat3(List<double> out, List<double> a, List<double> m) List<double>
Transforms the vec2 with a mat3 3rd vector component is implicitly '1'
transformMat4(List<double> out, List<double> a, List<double> m) List<double>
Transforms the vec2 with a mat4 3rd vector component is implicitly '0' 4th vector component is implicitly '1'
zero(dynamic out) List<double>
Set the components of a vec2 to zero