-
Notifications
You must be signed in to change notification settings - Fork 7
/
pow3.go
55 lines (47 loc) · 1.71 KB
/
pow3.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
// Pow3 returns a new vector with each component raised to the power of 3.
// Doesn't support fractional exponents.
func (v V2F[T]) Pow3() V2F[T] {
return V2F[T]{X: v.X * v.X * v.X, Y: v.Y * v.Y * v.Y}
}
// Pow3InPlace modifies vector by setting value of each component to the power of 3.
// Doesn't support fractional exponents.
func (v *V2F[T]) Pow3InPlace() {
v.X = v.X * v.X * v.X
v.Y = v.Y * v.Y * v.Y
}
// Pow3 returns a new vector with each component raised to the power of 3.
// Doesn't support fractional exponents.
func (v V3F[T]) Pow3() V3F[T] {
return V3F[T]{X: v.X * v.X * v.X, Y: v.Y * v.Y * v.Y, Z: v.Z * v.Z * v.Z}
}
// Pow3InPlace modifies vector by setting value of each component to the power of 3.
// Doesn't support fractional exponents.
func (v *V3F[T]) Pow3InPlace() {
v.X = v.X * v.X * v.X
v.Y = v.Y * v.Y * v.Y
v.Z = v.Z * v.Z * v.Z
}
// Pow3 returns a new vector with each component raised to the power of 3.
// Doesn't support fractional exponents.
func (v V2I[T]) Pow3() V2I[T] {
return V2I[T]{X: v.X * v.X * v.X, Y: v.Y * v.Y * v.Y}
}
// Pow3InPlace modifies vector by setting value of each component to the power of 3.
// Doesn't support fractional exponents.
func (v *V2I[T]) Pow3InPlace() {
v.X = v.X * v.X * v.X
v.Y = v.Y * v.Y * v.Y
}
// Pow3 returns a new vector with each component raised to the power of 3.
// Doesn't support fractional exponents.
func (v V3I[T]) Pow3() V3I[T] {
return V3I[T]{X: v.X * v.X * v.X, Y: v.Y * v.Y * v.Y, Z: v.Z * v.Z * v.Z}
}
// Pow3InPlace modifies vector by setting value of each component to the power of 3.
// Doesn't support fractional exponents.
func (v *V3I[T]) Pow3InPlace() {
v.X = v.X * v.X * v.X
v.Y = v.Y * v.Y * v.Y
v.Z = v.Z * v.Z * v.Z
}