Vec3 class

3-dimensional vector @example final v = new Vec3(1, 2, 3) console.log('x=' + v.x) // x=1

Constructors

Vec3([double x = 0.0, double y = 0.0, double z = 0.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

addScaledVector(double scalar, Vec3 vector, [Vec3? target]) Vec3
Scale a vector and add it to this vector. Save the result in "target". (target = this + vector * scalar) @param target The vector to save the result in.
almostEquals(Vec3 vector, [double? precision]) bool
Check if a vector equals is almost equal to another one.
almostZero([double precision = 1e-6]) bool
Check if a vector is almost zero
clone() Vec3
Clone the vector
copy(Vec3 vector) Vec3
Copies value of source to this vector.
cross(Vec3 vector, [Vec3? target]) Vec3
Vector cross product @param target Optional target to save in.
crossmat() Mat3
Get the cross product matrix a_cross from a vector, such that a x b = a_cross * b = c
crossVectors(Vec3 a, Vec3 b) Vec3
distanceSquared(Vec3 p) double
Get squared distance from this point to another point
distanceTo(Vec3 p) double
Get distance from this point to another point
dot(Vec3 vector) double
Calculate dot product @param vector
inverse() Vec3
Vector cross product @param target Optional target to save in.
isAntiparallelTo(Vec3 vector, [double? precision]) bool
Check if the vector is anti-parallel to another vector. @param precision Set to zero for exact comparisons
isZero() bool
length() double
Get the length of the vector
lengthSquared() double
Get the squared length of the vector.
lerp(Vec3 vector, double t, Vec3 target) → void
Do a linear interpolation between two vectors @param t A number between 0 and 1. 0 will make this function return u, and 1 will make it return v. Numbers in between will generate a vector in between them.
negate(Vec3 target) Vec3
Make the vector point in the opposite direction. @param target Optional target to save in
normalize() double
Normalize the vector. Note that this changes the values in the vector. @return Returns the norm of the vector
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scale(double scalar, [Vec3? target]) Vec3
Multiply all the components of the vector with a scalar. @param target The vector to save the result in.
set(double x, double y, double z) Vec3
Set the vectors' 3 elements
setZero() → void
Set all components of the vector to zero.
subVectors(Vec3 a, Vec3 b) Vec3
sum() int
tangents(Vec3 t1, Vec3 t2) → void
Compute two artificial tangents to the vector @param t1 Vector object to save the first tangent in @param t2 Vector object to save the second tangent in
toArray() List<double>
Converts to an array
toQuant() Quaternion
toString() String
Converts to a more readable format
override
unit([Vec3? target]) Vec3
Get the version of this vector that is of length 1. @param target Optional target to save in @return Returns the unit vector
vadd(Vec3 vector, [Vec3? target]) Vec3
Vector addition
vmul(Vec3 vector, [Vec3? target]) Vec3
Multiply the vector with an other vector, component-wise. @param target The vector to save the result in.
vsub(Vec3 vector, [Vec3? target]) Vec3
Vector subtraction @param target Optional target to save in.

Operators

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

Static Properties

unitX Vec3
getter/setter pair
unitY Vec3
getter/setter pair
unitZ Vec3
getter/setter pair
zero Vec3
getter/setter pair