-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
41 lines (35 loc) · 800 Bytes
/
util.go
File metadata and controls
41 lines (35 loc) · 800 Bytes
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
// SPDX-FileCopyrightText: 2025 Dominik Honnef and contributors
//
// SPDX-License-Identifier: MIT
package curve
import (
"math"
"honnef.co/go/stuff/math/mathutil"
)
func pow2(d float64) float64 { return d * d }
func pow3(d float64) float64 { return d * d * d }
func pow4(d float64) float64 { dd := d * d; return dd * dd }
func pow6(d float64) float64 {
dd := d * d
return dd * dd * dd
}
func pow7(d float64) float64 {
dd := d * d
return dd * dd * dd * d
}
func pow9(d float64) float64 {
dd := d * d
dddd := dd * dd
return dddd * dddd * d
}
// normalizeAngle normalizes angles to [0, 2π].
func normalizeAngle(a Angle) Angle {
a = math.Mod(a, 2*math.Pi)
if a < 0 {
a += 2 * math.Pi
}
return a
}
func clampAngle(a Angle) Angle {
return mathutil.Clamp(a, -2*math.Pi, 2*math.Pi)
}