Vector2 class

2D column vector.

Implemented types
Implementers
Available extensions

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

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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent 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.