Vector2 class Null safety

2D column vector.

Implemented types

Constructors

Vector2(double x, double y)
Construct a new vector with the specified values.
factory
Vector2.all(double value)
Splat value into all lanes of the vector.
factory
Vector2.array(List<double> array, [int offset = 0])
Initialized with values from array starting at offset.
factory
Vector2.copy(Vector2 other)
Copy of other.
factory
Vector2.fromBuffer(ByteBuffer buffer, int offset)
Constructs Vector2 with a storage that views given buffer starting at offset. offset has to be multiple of Float64List.bytesPerElement.
Vector2.fromFloat64List(Float64List _v2storage)
Constructs Vector2 with a given Float64List as storage.
Vector2.random([Random? rng])
Generate random vector in the range (0, 0) to (1, 1). You can optionally pass your own random number generator.
factory
Vector2.zero()
Zero vector.

Properties

g ↔ double
read / write
gg → Vector2
read-only
ggg → Vector3
read-only
gggg → Vector4
read-only
gggr → Vector4
read-only
ggr → Vector3
read-only
ggrg → Vector4
read-only
ggrr → Vector4
read-only
gr ↔ Vector2
read / write
grg → Vector3
read-only
grgg → Vector4
read-only
grgr → Vector4
read-only
grr → Vector3
read-only
grrg → Vector4
read-only
grrr → Vector4
read-only
hashCode → int
The hash code for this object.
read-onlyoverride
isInfinite → bool
True if any component is infinite.
read-only
isNaN → bool
True if any component is NaN.
read-only
length ↔ double
Length.
read / write
length2 → double
Length squared.
read-only
r ↔ double
read / write
rg ↔ Vector2
read / write
rgg → Vector3
read-only
rggg → Vector4
read-only
rggr → Vector4
read-only
rgr → Vector3
read-only
rgrg → Vector4
read-only
rgrr → Vector4
read-only
rr → Vector2
read-only
rrg → Vector3
read-only
rrgg → Vector4
read-only
rrgr → Vector4
read-only
rrr → Vector3
read-only
rrrg → Vector4
read-only
rrrr → Vector4
read-only
runtimeType → Type
A representation of the runtime type of the object.
read-onlyinherited
s ↔ double
read / write
ss → Vector2
read-only
sss → Vector3
read-only
ssss → Vector4
read-only
ssst → Vector4
read-only
sst → Vector3
read-only
ssts → Vector4
read-only
sstt → Vector4
read-only
st ↔ Vector2
read / write
storage → Float64List
The components of the vector.
read-onlyoverride
sts → Vector3
read-only
stss → Vector4
read-only
stst → Vector4
read-only
stt → Vector3
read-only
stts → Vector4
read-only
sttt → Vector4
read-only
t ↔ double
read / write
ts ↔ Vector2
read / write
tss → Vector3
read-only
tsss → Vector4
read-only
tsst → Vector4
read-only
tst → Vector3
read-only
tsts → Vector4
read-only
tstt → Vector4
read-only
tt → Vector2
read-only
tts → Vector3
read-only
ttss → Vector4
read-only
ttst → Vector4
read-only
ttt → Vector3
read-only
ttts → Vector4
read-only
tttt → Vector4
read-only
x ↔ double
read / write
xx → Vector2
read-only
xxx → Vector3
read-only
xxxx → Vector4
read-only
xxxy → Vector4
read-only
xxy → Vector3
read-only
xxyx → Vector4
read-only
xxyy → Vector4
read-only
xy ↔ Vector2
read / write
xyx → Vector3
read-only
xyxx → Vector4
read-only
xyxy → Vector4
read-only
xyy → Vector3
read-only
xyyx → Vector4
read-only
xyyy → Vector4
read-only
y ↔ double
read / write
yx ↔ Vector2
read / write
yxx → Vector3
read-only
yxxx → Vector4
read-only
yxxy → Vector4
read-only
yxy → Vector3
read-only
yxyx → Vector4
read-only
yxyy → Vector4
read-only
yy → Vector2
read-only
yyx → Vector3
read-only
yyxx → Vector4
read-only
yyxy → Vector4
read-only
yyy → Vector3
read-only
yyyx → Vector4
read-only
yyyy → Vector4
read-only

Methods

absolute() → void
Absolute value.
absoluteError(Vector2 correct) → double
Absolute error between this and correct
add(Vector2 arg) → void
Add arg to this.
addScaled(Vector2 arg, double factor) → void
Add arg scaled by factor to this.
angleTo(Vector2 other) → double
Returns the angle between this vector and other in radians.
angleToSigned(Vector2 other) → double
Returns the signed angle between this and other in radians.
ceil() → void
Ceil entries in this.
clamp(Vector2 min, Vector2 max) → void
Clamp each entry n in this in the range [minn]-[maxn].
clampScalar(double min, double max) → void
Clamp entries this in the range min-max.
clone() → Vector2
Clone of this.
copyFromArray(List<double> array, [int offset = 0]) → void
Copies elements from array into this starting at offset.
copyInto(Vector2 arg) → Vector2
Copy this into arg. Returns arg.
copyIntoArray(List<double> array, [int offset = 0]) → void
Copies this into array starting at offset.
cross(Vector2 other) → double
Cross product.
distanceTo(Vector2 arg) → double
Distance from this to arg
distanceToSquared(Vector2 arg) → double
Squared distance from this to arg
divide(Vector2 arg) → void
Divide entries in this with entries in arg.
dot(Vector2 other) → double
Inner product.
floor() → void
Floor entries in this.
multiply(Vector2 arg) → void
Multiply entries in this with entries in arg.
negate() → void
Negate.
normalize() → double
Normalize this.
normalized() → Vector2
Normalized copy of this.
normalizeInto(Vector2 out) → Vector2
Normalize vector into out.
normalizeLength() → double
Normalize this. Returns length of vector before normalization. DEPRECATED: Use normalize.
Deprecated('Use normalize() insteaed.')">@Deprecated('Use normalize() insteaed.')
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
postmultiply(Matrix2 arg) → void
Transforms this into the product of this as a row vector, postmultiplied by matrix, arg. If arg is a rotation matrix, this is a computational shortcut for applying, the inverse of the transformation.
reflect(Vector2 normal) → void
Reflect this.
reflected(Vector2 normal) → Vector2
Reflected copy of this.
relativeError(Vector2 correct) → double
Relative error between this and correct
round() → void
Round entries in this.
roundToZero() → void
Round entries in this towards zero.
scale(double arg) → void
Scale this by arg.
scaled(double arg) → Vector2
Return a copy of this scaled by arg.
scaleOrthogonalInto(double scale, Vector2 out) → Vector2
Rotate this by 90 degrees then scale it. Store result in out. Return out.
setFrom(Vector2 other) → void
Set the values by copying them from other.
setValues(double x_, double y_) → void
Set the values of the vector.
setZero() → void
Zero the vector.
splat(double arg) → void
Splat arg into all lanes of the vector.
sub(Vector2 arg) → void
Subtract arg from this.
toString() → String
Returns a printable string
override

Operators

operator *(double scale) → Vector2
Scale.
operator +(Vector2 other) → Vector2
Add two vectors.
operator -(Vector2 other) → Vector2
Subtract two vectors.
operator /(double scale) → Vector2
Scale.
operator ==(Object? other) → bool
Check if two vectors are the same.
override
operator [](int i) → double
Access the component of the vector at the index i.
operator []=(int i, double v) → void
Set the component of the vector at the index i.
operator unary-() → Vector2
Negate.

Static Methods

max(Vector2 a, Vector2 b, Vector2 result) → void
Set the values of result to the maximum of a and b for each line.
min(Vector2 a, Vector2 b, Vector2 result) → void
Set the values of result to the minimum of a and b for each line.
mix(Vector2 min, Vector2 max, double a, Vector2 result) → void
Interpolate between min and max with the amount of a using a linear interpolation and store the values in result.