Vector Scalar Operations
Example
import slash.vector.*
val v1 = Vec[2](1.5, 2.5)
// v1: Vec[2] = Array(1.5, 2.5)
v1 + 2.0
// res0: Vec[2] = Array(3.5, 4.5)
v1 - 2.0
// res1: Vec[2] = Array(-0.5, 0.5)
v1 * 2.0
// res2: Vec[2] = Array(3.0, 5.0)
v1 / 2.0
// res3: Vec[2] = Array(0.75, 1.25)
v1.unary_-
// res4: Vec[2] = Array(-1.5, -2.5)
// mutating (no copy) methods
val v2A = Vec[2](1.5, 2.5)
// v2A: Vec[2] = Array(4.0, 5.0)
v2A += 2.5
v2A.show
// res6: String = "《²↗〉4.0ᵢ 5.0ⱼ〉"
val v2B = Vec[2](1.5, 2.5)
// v2B: Vec[2] = Array(-1.0, 0.0)
v2B -= 2.5
v2B.show
// res8: String = "《²↗〉-1.0ᵢ 0.0ⱼ〉"
val v2C = Vec[2](1.5, 2.5)
// v2C: Vec[2] = Array(3.75, 6.25)
v2C *= 2.5
v2C.show
// res10: String = "《²↗〉3.75ᵢ 6.25ⱼ〉"
val v2D = Vec[2](1.5, 2.5)
// v2D: Vec[2] = Array(0.6000000000000001, 1.0)
v2D /= 2.5
v2D
// res12: Vec[2] = Array(0.6000000000000001, 1.0)
v1.clampedMin(2.0).show
// res13: String = "《²↗〉2.0ᵢ 2.5ⱼ〉"
v1.clampedMAX(2.0).show
// res14: String = "《²↗〉1.5ᵢ 2.0ⱼ〉"
val v2 = Vec[3](1.5, 2.5, 3.5)
// v2: Vec[3] = Array(1.5, 2.5, 3.5)
v2.clamped(2.0, 3.0)
// res15: Vec[3] = Array(2.0, 2.5, 3.0)