math: Add trigonometric functions and some angle helper functions

This commit adds these new template functions in the `math` namespace:

math.Acos
math.Asin
math.Atan
math.Atan2
math.Cos
math.Pi
math.Sin
math.Tan
math.ToDegrees
math.ToRadians

Co-authored-by: Joe Mooring <joe@mooring.com>
This commit is contained in:
raoulb 2024-07-29 11:05:36 +02:00 committed by GitHub
parent 0e00561620
commit 9d2b5f98d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 933 additions and 54 deletions

View file

@ -0,0 +1,24 @@
---
title: math.Acos
description: Returns the arccosine, in radians, of the given number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Asin
- functions/math/Atan
- functions/math/Atan2
- functions/math/Pi
- functions/math/Sin
- functions/math/Cos
- functions/math/Tan
returnType: float64
signatures: [math.Acos VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Acos 1 }} → 0
```

View file

@ -0,0 +1,24 @@
---
title: math.Asin
description: Returns the arcsine, in radians, of the given number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Acos
- functions/math/Atan
- functions/math/Atan2
- functions/math/Pi
- functions/math/Sin
- functions/math/Cos
- functions/math/Tan
returnType: float64
signatures: [math.Asin VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Asin 1 }} → 1.5707963267948966
```

View file

@ -0,0 +1,24 @@
---
title: math.Atan
description: Returns the arctangent, in radians, of the given number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Atan2
- functions/math/Asin
- functions/math/Acos
- functions/math/Pi
- functions/math/Sin
- functions/math/Cos
- functions/math/Tan
returnType: float64
signatures: [math.Atan VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Atan 1 }} → 0.7853981633974483
```

View file

@ -0,0 +1,24 @@
---
title: math.Atan2
description: Returns the arctangent, in radians, of the given number pair, determining the correct quadrant from their signs.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Atan
- functions/math/Asin
- functions/math/Acos
- functions/math/Pi
- functions/math/Sin
- functions/math/Cos
- functions/math/Tan
returnType: float64
signatures: [math.Atan2 VALUE VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Atan2 1 2 }} → 0.4636476090008061
```

View file

@ -0,0 +1,24 @@
---
title: math.Cos
description: Returns the cosine of the given radian number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Pi
- functions/math/Sin
- functions/math/Tan
- functions/math/Asin
- functions/math/Acos
- functions/math/Atan
- functions/math/Atan2
returnType: float64
signatures: [math.Cos VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Cos 1 }} → 0.5403023058681398
```

View file

@ -0,0 +1,24 @@
---
title: math.Pi
description: Returns the mathematical constant pi.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Sin
- functions/math/Cos
- functions/math/Tan
- functions/math/Asin
- functions/math/Acos
- functions/math/Atan
- functions/math/Atan2
returnType: float64
signatures: [math.Pi]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Pi }} → 3.141592653589793
```

View file

@ -0,0 +1,24 @@
---
title: math.Sin
description: Returns the sine of the given radian number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Pi
- functions/math/Cos
- functions/math/Tan
- functions/math/Asin
- functions/math/Acos
- functions/math/Atan
- functions/math/Atan2
returnType: float64
signatures: [math.Sin VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Sin 1 }} → 0.8414709848078965
```

View file

@ -0,0 +1,24 @@
---
title: math.Tan
description: Returns the tangent of the given radian number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Pi
- functions/math/Sin
- functions/math/Cos
- functions/math/Asin
- functions/math/Acos
- functions/math/Atan
- functions/math/Atan2
returnType: float64
signatures: [math.Tan VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.Tan 1 }} → 1.557407724654902
```

View file

@ -0,0 +1,19 @@
---
title: math.ToDegrees
description: ToDegrees converts radians into degrees.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/ToRadians
- functions/math/Pi
returnType: float64
signatures: [math.ToDegrees VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.ToDegrees 1.5707963267948966 }} → 90
```

View file

@ -0,0 +1,19 @@
---
title: math.ToRadians
description: ToRadians converts degrees into radians.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/ToDegrees
- functions/math/Pi
returnType: float64
signatures: [math.ToRadians VALUE]
---
{{< new-in 0.130.0 >}}
```go-html-template
{{ math.ToRadians 90 }} → 1.5707963267948966
```