Vector3 class

Class representing a 3D vector.

@author {@link https://github.com/Mugen87|Mugen87}

Constructors

Vector3([double? x, double? y, double? z])
Constructs a new 3D vector with the given values.

Properties

hashCode → int
The hash code for this object.
no setterinherited
length → double
Computes the length of this 3D vector.
no setter
manhattanLength → double
Computes the manhattan length of this 3D vector.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
squaredLength → double
Computes the squared length of this 3D vector. Calling this method is faster than calling {@link Vector3#length}, since it avoids computing a square root.
no setter
storage → Float32List
final
x ↔ double
getter/setter pair
y ↔ double
getter/setter pair
z ↔ double
getter/setter pair

Methods

add(Vector3 v) → Vector3
Adds the given 3D vector to this 3D vector.
addScalar(double s) → Vector3
Adds the given scalar to this 3D vector.
addVectors(Vector3 a, Vector3 b) → Vector3
Adds two given 3D vectors and stores the result in this 3D vector.
angleTo(Vector3 v) → double
Computes the angle between this and the given vector.
applyMatrix4(Matrix4 m) → Vector3
Multiplies the given 4x4 matrix with this 3D vector
applyRotation(Quaternion q) → Vector3
Multiplies the given quaternion with this 3D vector.
clamp(Vector3 min, Vector3 max) → Vector3
Ensures this 3D vector lies in the given min/max range.
clone() → Vector3
Creates a new 3D vector and copies all values from this 3D vector.
copy(Vector3 v) → Vector3
Copies all values from the given 3D vector to this 3D vector.
cross(Vector3 v) → Vector3
Computes the cross product of this and the given 3D vector and stores the result in this 3D vector.
crossVectors(Vector3 a, Vector3 b) → Vector3
Computes the cross product of the two given 3D vectors and stores the result in this 3D vector.
distanceTo(Vector3 v) → double
Computes the euclidean distance between this 3D vector and the given one.
divide(Vector3 v) → Vector3
Divides the given 3D vector through this 3D vector.
divideScalar(double s) → Vector3
Divides the given scalar through this 3D vector.
divideVectors(Vector3 a, Vector3 b) → Vector3
Divides two given 3D vectors and stores the result in this 3D vector.
dot(Vector3 v) → double
Computes the dot product of this and the given 3D vector.
equals(Vector3 v) → bool
Returns true if the given 3D vector is deep equal with this 3D vector.
extractPositionFromMatrix(Matrix4 m) → Vector3
Extracts the position portion of the given 4x4 matrix and stores it in this 3D vector.
fromArray(List<double> array, [int offset = 0]) → Vector3
Sets the components of this 3D vector from an array.
fromMatrix3Column(Matrix3 m, int i) → Vector3
Sets the components of this 3D vector from a column of a 3x3 matrix.
fromMatrix4Column(Matrix4 m, int i) → Vector3
Sets the components of this 3D vector from a column of a 4x4 matrix.
fromSpherical(double radius, double phi, double theta) → Vector3
Sets the components of this 3D vector from a spherical coordinate.
fromUnknown(List array, [int offset = 0]) → Vector3
manhattanDistanceTo(Vector3 v) → double
Computes the manhattan distance between this 3D vector and the given one.
max(Vector3 v) → Vector3
Compares each vector component of this 3D vector and the given one and stores the maximum value in this instance.
min(Vector3 v) → Vector3
Compares each vector component of this 3D vector and the given one and stores the minimum value in this instance.
multiply(Vector3 v) → Vector3
Multiplies the given 3D vector with this 3D vector.
multiplyScalar(double s) → Vector3
Multiplies the given scalar with this 3D vector.
multiplyVectors(Vector3 a, Vector3 b) → Vector3
Multiplies two given 3D vectors and stores the result in this 3D vector.
normalize() → Vector3
Normalizes this 3D vector.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reflect(Vector3 normal) → Vector3
Reflects this vector along the given normal.
set(double x, double y, double z) → Vector3
Sets the given values to this 3D vector.
squaredDistanceTo(Vector3 v) → double
Computes the squared euclidean distance between this 3D vector and the given one. Calling this method is faster than calling {@link Vector3#distanceTo}, since it avoids computing a square root.
sub(Vector3 v) → Vector3
Subtracts the given 3D vector from this 3D vector.
subScalar(double s) → Vector3
Subtracts the given scalar from this 3D vector.
subVectors(Vector3 a, Vector3 b) → Vector3
Subtracts two given 3D vectors and stores the result in this 3D vector.
toArray(List<double> array, [int offset = 0]) → List<double>
Copies all values of this 3D vector to the given array.
toString() → String
A string representation of this object.
inherited
transformDirection(Matrix4 m) → Vector3
Transform this direction vector by the given 4x4 matrix.

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](int i) → double
operator []=(int i, double v) → void