-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlenSqrt.go
25 lines (21 loc) · 874 Bytes
/
lenSqrt.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
package govec
// LenSqrt calculates the length of the vector without the square root.
// This is useful for comparing lengths without the overhead of a square root.
func (v V2F[T]) LenSqrt() T {
return v.X*v.X + v.Y*v.Y
}
// LenSqrt calculates the length of the vector without the square root.
// This is useful for comparing lengths without the overhead of a square root.
func (v V3F[T]) LenSqrt() T {
return v.X*v.X + v.Y*v.Y + v.Z*v.Z
}
// LenSqrt calculates the length of the vector without the square root.
// This is useful for comparing lengths without the overhead of a square root.
func (v V2I[T]) LenSqrt() T {
return v.X*v.X + v.Y*v.Y
}
// LenSqrt calculates the length of the vector without the square root.
// This is useful for comparing lengths without the overhead of a square root.
func (v V3I[T]) LenSqrt() T {
return v.X*v.X + v.Y*v.Y + v.Z*v.Z
}