-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinv.go
55 lines (43 loc) · 1.17 KB
/
inv.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
// Inv returns a new V2F[T] with components inverted (1/x).
func (v V2F[T]) Inv() V2F[T] {
return V2F[T]{X: 1 / v.X, Y: 1 / v.Y}
}
// InvInPlace modifies vector by setting components to their inverse (1/x).
func (v *V2F[T]) InvInPlace() {
v.X = 1 / v.X
v.Y = 1 / v.Y
}
// V3F
// Inv returns a new V3F[T] with components inverted (1/x).
func (v V3F[T]) Inv() V3F[T] {
return V3F[T]{X: 1 / v.X, Y: 1 / v.Y, Z: 1 / v.Z}
}
// InvInPlace modifies vector by setting components to their inverse (1/x).
func (v *V3F[T]) InvInPlace() {
v.X = 1 / v.X
v.Y = 1 / v.Y
v.Z = 1 / v.Z
}
// V2I
// Inv returns a new V2I[T] with components inverted (1/x).
func (v V2I[T]) Inv() V2I[T] {
return V2I[T]{X: 1 / v.X, Y: 1 / v.Y}
}
// InvInPlace modifies vector by setting components to their inverse (1/x).
func (v *V2I[T]) InvInPlace() {
v.X = 1 / v.X
v.Y = 1 / v.Y
}
// V3I
// Inv returns a new V3I[T] with components inverted (1/x).
func (v V3I[T]) Inv() V3I[T] {
return V3I[T]{X: 1 / v.X, Y: 1 / v.Y, Z: 1 / v.Z}
}
// InvInPlace modifies vector by setting components to their inverse (1/x).
func (v *V3I[T]) InvInPlace() {
v.X = 1 / v.X
v.Y = 1 / v.Y
v.Z = 1 / v.Z
}