2018-10-14 03:07:28 +02:00
|
|
|
package math
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2018-10-14 19:06:27 +02:00
|
|
|
|
2018-10-14 03:07:28 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
|
|
)
|
|
|
|
|
2018-10-14 19:06:27 +02:00
|
|
|
// Radians returns the angle converted from degrees to radians.
|
|
|
|
// @param number (Float|Int) - The input number.
|
|
|
|
// @returns (Float) - The angle in radians.
|
2018-10-14 03:07:28 +02:00
|
|
|
func Radians(_ context.Context, args ...core.Value) (core.Value, error) {
|
|
|
|
err := core.ValidateArgs(args, 1, 1)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return values.None, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = core.ValidateType(args[0], core.IntType, core.FloatType)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return values.None, err
|
|
|
|
}
|
|
|
|
|
|
|
|
r := toFloat(args[0])
|
|
|
|
|
|
|
|
return values.NewFloat(r * DegToRad), nil
|
|
|
|
}
|