Vector2 class
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 atoffset
.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 atoffset
.offset
has to be multiple of Float32List.bytesPerElement. - Vector2.fromFloat32List(Float32List _v2storage)
- Constructs Vector2 with a given Float32List 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-only, override
- 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
- 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 → Float32List
-
The components of the vector.
read-only, override
- 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
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
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 byfactor
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 [min
n
]-[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 atoffset
. -
copyInto(
Vector2 arg) → Vector2 -
Copy this into
arg
. Returnsarg
. -
copyIntoArray(
List< double> array, [ int offset = 0 ]) → void -
Copies this into
array
starting atoffset
. -
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.
-
postmultiply(
Matrix2 arg) → void -
Transforms this into the product of this as a row vector,
postmultiplied by matrix,
arg
. Ifarg
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
. Returnout
. -
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
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 ofa
andb
for each line. -
min(
Vector2 a, Vector2 b, Vector2 result) → void -
Set the values of
result
to the minimum ofa
andb
for each line. -
mix(
Vector2 min, Vector2 max, double a, Vector2 result) → void -
Interpolate between
min
andmax
with the amount ofa
using a linear interpolation and store the values inresult
.