-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpowNFloat.go
55 lines (46 loc) · 2.01 KB
/
powNFloat.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
import "math"
// PowNFloat returns a new vector with each component raised to the power of n.
// Supports fractional exponents.
func (v V2F[T]) PowNFloat(n float64) V2F[T] {
return V2F[T]{X: T(math.Pow(float64(v.X), n)), Y: T(math.Pow(float64(v.Y), n))}
}
// PowNFloatInPlace modifies vector by setting value of each component to the power of n.
// Supports fractional exponents.
func (v *V2F[T]) PowNFloatInPlace(n float64) {
v.X = T(math.Pow(float64(v.X), n))
v.Y = T(math.Pow(float64(v.Y), n))
}
// PowNFloat returns a new vector with each component raised to the power of n.
// Supports fractional exponents.
func (v V3F[T]) PowNFloat(n float64) V3F[T] {
return V3F[T]{X: T(math.Pow(float64(v.X), n)), Y: T(math.Pow(float64(v.Y), n)), Z: T(math.Pow(float64(v.Z), n))}
}
// PowNFloatInPlace modifies vector by setting value of each component to the power of n.
// Supports fractional exponents.
func (v *V3F[T]) PowNFloatInPlace(n float64) {
v.X = T(math.Pow(float64(v.X), n))
v.Y = T(math.Pow(float64(v.Y), n))
v.Z = T(math.Pow(float64(v.Z), n))
}
// PowNFloat returns a new vector with each component raised to the power of n.
// Supports fractional exponents.
func (v V2I[T]) PowNFloat(n float64) V2I[T] {
return V2I[T]{X: T(math.Pow(float64(v.X), n)), Y: T(math.Pow(float64(v.Y), n))}
}
// PowNFloatInPlace modifies vector by setting value of each component to the power of n.
// Supports fractional exponents.
func (v *V2I[T]) PowNFloatInPlace(n float64) {
v.X = T(math.Pow(float64(v.X), n))
v.Y = T(math.Pow(float64(v.Y), n))
}
// PowNFloat returns a new vector with each component raised to the power of n.
func (v V3I[T]) PowNFloat(n float64) V3I[T] {
return V3I[T]{X: T(math.Pow(float64(v.X), n)), Y: T(math.Pow(float64(v.Y), n)), Z: T(math.Pow(float64(v.Z), n))}
}
// PowNFloatInPlace modifies vector by setting value of each component to the power of n.
func (v *V3I[T]) PowNFloatInPlace(n float64) {
v.X = T(math.Pow(float64(v.X), n))
v.Y = T(math.Pow(float64(v.Y), n))
v.Z = T(math.Pow(float64(v.Z), n))
}