-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdot.go
49 lines (37 loc) · 1018 Bytes
/
dot.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
package govec
// V2F
// Dot returns the dot product of given vectors.
func (v V2F[T]) Dot(v2 V2F[T]) T {
return v.X*v2.X + v.Y*v2.Y
}
// DotComp returns the dot product of given vectors.
func (v V2F[T]) DotComp(x T, y T) T {
return v.X*x + v.Y*y
}
// V3F
// Dot returns the dot product of given vectors.
func (v V3F[T]) Dot(v2 V3F[T]) T {
return v.X*v2.X + v.Y*v2.Y + v.Z*v2.Z
}
// DotComp returns the dot product of given vectors.
func (v V3F[T]) DotComp(x T, y T, z T) T {
return v.X*x + v.Y*y + v.Z*z
}
// V2I
// Dot returns the dot product of given vectors.
func (v V2I[T]) Dot(v2 V2I[T]) T {
return v.X*v2.X + v.Y*v2.Y
}
// DotComp returns the dot product of given vectors.
func (v V2I[T]) DotComp(x T, y T) T {
return v.X*x + v.Y*y
}
// V3I
// Dot returns the dot product of given vectors.
func (v V3I[T]) Dot(v2 V3I[T]) T {
return v.X*v2.X + v.Y*v2.Y + v.Z*v2.Z
}
// DotComp returns the dot product of given vectors.
func (v V3I[T]) DotComp(x T, y T, z T) T {
return v.X*x + v.Y*y + v.Z*z
}