trait Vector extends AnyRef
Mixin representing a 2D vector.
The methods of this mixin won't alter the values of the classes that extends it.
- Alphabetic
- By Inheritance
- Vector
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
Concrete Value Members
-
def
add(v: Vector): Vector
Vector addition.
Vector addition. Leaves this vector unchanged.
- v
vector to add
- returns
addition result as a new instance
-
def
divide(v: Double): Vector
Vector-scalar division.
Vector-scalar division. Leaves this vector unchanged.
- v
scalar
- returns
division result as a new instance
-
def
dot(v: Vector): Double
Vector dot product
Vector dot product
- v
vector to use for dot product
- returns
dot product
-
def
getMagnitude: Double
Gets the magnitude (module) of the vector applying parallelogram law
Gets the magnitude (module) of the vector applying parallelogram law
- returns
magnitude of this vector
-
def
getNewMagnitude(desiredMagnitude: Double): Vector
Scales this vector magnitude (module) with the desired one
Scales this vector magnitude (module) with the desired one
- desiredMagnitude
desired vector magnitude
- returns
a new vector with the specified module
-
def
limit(maxMagnitude: Double): Vector
Limits the vector's magnitude if it is greater than the given one
Limits the vector's magnitude if it is greater than the given one
- maxMagnitude
the max magnitude of the vector
- returns
a new vector
-
def
multiply(v: Double): Vector
Vector-scalar multiplication.
Vector-scalar multiplication. Leaves this vector unchanged.
- v
scalar to multiply
- returns
multiplication mu result as a new instance
-
def
multiply(v: Vector): Vector
Vector multiplication.
Vector multiplication. Leaves this vector unchanged.
- v
vector to multiply
- returns
multiplication result as a new instance
-
def
normalized(): Vector
Gets the vector normalized
Gets the vector normalized
- returns
a new normalized instance of this vector
-
def
subtract(v: Vector): Vector
Vector subtraction.
Vector subtraction. Leaves this vector unchanged.
- v
vector to subtract
- returns
subtraction result as a new instance