- Replace double.DegreesToRadians/RadiansToDegrees with Math-based conversions - Replace Random.Shared with thread-local Random for thread safety
34 lines
923 B
C#
34 lines
923 B
C#
namespace CSMic.StandardLibrary.Functions.Angle
|
|
{
|
|
public class Radians : FunctionBase, ICodedFunction
|
|
{
|
|
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return "radians";
|
|
}
|
|
}
|
|
|
|
public override IEnumerable<FunctionArgument> ExpectedArguments
|
|
{
|
|
get
|
|
{
|
|
yield return new FunctionArgument("value", FunctionValue.NUMBER);
|
|
}
|
|
}
|
|
|
|
public FunctionValue Execute(params FunctionArgument[] args)
|
|
{
|
|
return Execute(args, (_args) =>
|
|
{
|
|
var input = _args[0].Value;
|
|
decimal value = Convert.ToDecimal(input.Value);
|
|
|
|
// Convert degrees to radians (compatible with .NET Standard)
|
|
return new FunctionValue(FunctionValueType.Numeric, (double)value * (Math.PI / 180.0));
|
|
});
|
|
}
|
|
}
|
|
}
|