-
Notifications
You must be signed in to change notification settings - Fork 7
/
powN.go
63 lines (51 loc) · 1.72 KB
/
powN.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
56
57
58
59
60
61
62
63
package govec
// V2F
// PowN returns a new vector with each component raised to the power of n.
// Doesn't support fractional exponents.
func (v V2F[T]) PowN(n int16) V2F[T] {
return V2F[T]{X: pow(v.X, n), Y: pow(v.Y, n)}
}
// PowNInPlace modifies vector by setting value of each component to the power of n.
// Doesn't support fractional exponents.
func (v *V2F[T]) PowNInPlace(n int16) {
v.X = pow(v.X, n)
v.Y = pow(v.Y, n)
}
// V3F
// PowN returns a new vector with each component raised to the power of n.
// Doesn't support fractional exponents.
func (v V3F[T]) PowN(n int16) V3F[T] {
return V3F[T]{X: pow(v.X, n), Y: pow(v.Y, n), Z: pow(v.Z, n)}
}
// PowNInPlace modifies vector by setting value of each component to the power of n.
// Doesn't support fractional exponents.
func (v *V3F[T]) PowNInPlace(n int16) {
v.X = pow(v.X, n)
v.Y = pow(v.Y, n)
v.Z = pow(v.Z, n)
}
// V2I
// PowN returns a new vector with each component raised to the power of n.
// Doesn't support fractional exponents.
func (v V2I[T]) PowN(n int16) V2I[T] {
return V2I[T]{X: pow(v.X, n), Y: pow(v.Y, n)}
}
// PowNInPlace modifies vector by setting value of each component to the power of n.
// Doesn't support fractional exponents.
func (v *V2I[T]) PowNInPlace(n int16) {
v.X = pow(v.X, n)
v.Y = pow(v.Y, n)
}
// V3I
// PowN returns a new vector with each component raised to the power of n.
// Doesn't support fractional exponents.
func (v V3I[T]) PowN(n int16) V3I[T] {
return V3I[T]{X: pow(v.X, n), Y: pow(v.Y, n), Z: pow(v.Z, n)}
}
// PowNInPlace modifies vector by setting value of each component to the power of n.
// Doesn't support fractional exponents.
func (v *V3I[T]) PowNInPlace(n int16) {
v.X = pow(v.X, n)
v.Y = pow(v.Y, n)
v.Z = pow(v.Z, n)
}