-
Notifications
You must be signed in to change notification settings - Fork 7
/
subScalar.go
55 lines (43 loc) · 1.39 KB
/
subScalar.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package govec
// V2F
// SubScalar returns a new vector with each component subtracted by scalar.
func (v V2F[T]) SubScalar(scalar T) V2F[T] {
return V2F[T]{X: v.X - scalar, Y: v.Y - scalar}
}
// SubScalarInPlace modifies vector by subtracting each component by scalar.
func (v *V2F[T]) SubScalarInPlace(scalar T) {
v.X -= scalar
v.Y -= scalar
}
// V3F
// SubScalar returns a new vector with each component subtracted by scalar.
func (v V3F[T]) SubScalar(scalar T) V3F[T] {
return V3F[T]{X: v.X - scalar, Y: v.Y - scalar, Z: v.Z - scalar}
}
// SubScalarInPlace modifies vector by subtracting each component by scalar.
func (v *V3F[T]) SubScalarInPlace(scalar T) {
v.X -= scalar
v.Y -= scalar
v.Z -= scalar
}
// V2I
// SubScalar returns a new vector with each component subtracted by scalar.
func (v V2I[T]) SubScalar(scalar T) V2I[T] {
return V2I[T]{X: v.X - scalar, Y: v.Y - scalar}
}
// SubScalarInPlace modifies vector by subtracting each component by scalar.
func (v *V2I[T]) SubScalarInPlace(scalar T) {
v.X -= scalar
v.Y -= scalar
}
// V3I
// SubScalar returns a new vector with each component subtracted by scalar.
func (v V3I[T]) SubScalar(scalar T) V3I[T] {
return V3I[T]{X: v.X - scalar, Y: v.Y - scalar, Z: v.Z - scalar}
}
// SubScalarInPlace modifies vector by subtracting each component by scalar.
func (v *V3I[T]) SubScalarInPlace(scalar T) {
v.X -= scalar
v.Y -= scalar
v.Z -= scalar
}