Vector3 class

Constructors

Vector3([double x = 0, double y = 0, double z = 0])

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
x double
getter/setter pair
y double
getter/setter pair
z double
getter/setter pair

Methods

add(Vector3 v) Vector3
Adds v to this vector.
addScalar(double s) Vector3
Adds the scalar value s to this vector's x, y and z values.
addScaledVector(Vector3 v, double s) Vector3
Adds the multiple of v and s to this vector.
addVectors(Vector3 a, Vector3 b) Vector3
Sets this vector to a + b.
angleTo(Vector3 v) double
Returns the angle between this vector and vector v in radians.
ceil() Vector3
The x, y and z components of this vector are rounded up to the nearest integer value.
clamp(Vector3 min, Vector3 max) Vector3
If this vector's x, y or z value is greater than the max vector's x, y or z value, it is replaced by the corresponding value.
clampLength(double min, double max) Vector3
If this vector's length is greater than the max value, the vector will be scaled down so its length is the max value.
clampScalar(double minVal, double maxVal) Vector3
If this vector's x, y or z values are greater than the max value, they are replaced by the max value.
clone() Vector3
Returns a new vector3 with the same x, y and z values as this one.
copy(Vector3 v) Vector3
Copies the values of the passed vector3's x, y and z properties to this vector3.
cross(Vector3 v) Vector3
Sets this vector to cross product of itself and v.
crossVectors(Vector3 a, Vector3 b) Vector3
Sets this vector to cross product of a and b.
distanceTo(Vector3 v) double
Computes the distance from this vector to v.
distanceToSquared(Vector3 v) double
Computes the squared distance from this vector to v. If you are just comparing the distance with another distance, you should compare the distance squared instead as it is slightly more efficient to calculate.
divide(Vector3 v) Vector3
Divides this vector by v.
divideScalar(double scalar) Vector3
Divides this vector by scalar s. Sets vector to ( 0, 0, 0 ) if s = 0.
dot(Vector3 v) double
Calculate the dot product of this vector and v.
floor() Vector3
The components of this vector are rounded down to the nearest integer value.
getComponent(int index) double
  • index - 0, 1 or 2.

  • If index equals 0 returns the x value.

  • If index equals 1 returns the y value.

  • If index equals 2 returns the z value.

  • length() double
    Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).
    lengthSq() double
    Computes the square of the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
    lerp(Vector3 v, double alpha) Vector3
    Linearly interpolate between this vector and v, where alpha is the percent distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.
    lerpVectors(Vector3 v1, Vector3 v2, dynamic alpha) Vector3
    Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the percent distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.
    manhattanDistanceTo(Vector3 v) double
    Computes the Manhattan distance from this vector to v.
    manhattanLength() double
    Computes the Manhattan length of this vector.
    max(Vector3 v) Vector3
    If this vector's x, y or z value is less than v's x, y or z value, replace that value with the corresponding max value.
    min(Vector3 v) Vector3
    If this vector's x, y or z value is greater than v's x, y or z value, replace that value with the corresponding min value.
    multiply(dynamic v) Vector3
    Multiplies this vector by v.
    multiplyScalar(double scalar) Vector3
    Multiplies this vector by scalar s.
    multiplyVectors(Vector3 a, Vector3 b) Vector3
    Sets this vector equal to a * b, component-wise
    negate() Vector3
    Inverts this vector - i.e. sets x = -x, y = -y and z = -z.
    normalize() Vector3
    Convert this vector to a unit vector - that is, sets it equal to a vector with the same direction as this one, but length 1.
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    projectOnPlane(Vector3 planeNormal) Vector3
    Projects this vector onto a plane by subtracting this vector projected onto the plane's normal from this vector.
    projectOnVector(Vector3 v) Vector3
    Projects this vector onto v.
    reflect(Vector3 normal) Vector3
    Reflect this vector off of plane orthogonal to normal. Normal is assumed to have unit length.
    round() Vector3
    The components of this vector are rounded to the nearest integer value.
    roundToZero() Vector3
    The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.
    set(double _x, double _y, double _z) Vector3
    Sets the x, y and z components of this vector.
    setComponent(int index, double value) Vector3
  • index - 0, 1 or 2.

  • value - Float

  • If index equals 0 set x to value.

  • If index equals 1 set y to value.

  • If index equals 2 set z to value

  • setLength(double length) Vector3
    Set this vector to a vector with the same direction as this one, but length l.
    setScalar(double scalar) Vector3
    Set the x, y and z values of this vector both equal to scalar.
    setX(double x) Vector3
    Replace this vector's x value with x.
    setY(double y) Vector3
    Replace this vector's y value with y.
    setZ(double z) Vector3
    Replace this vector's z value with z.
    sub(Vector3 v) Vector3
    Subtracts v from this vector.
    subScalar(double s) Vector3
    Subtracts s from this vector's x, y and z compnents.
    subVectors(Vector3 a, Vector3 b) Vector3
    Sets this vector to a - b.
    toString() String
    A string representation of this object.
    inherited

    Operators

    operator ==(Object other) bool
    The equality operator.
    inherited