2026-08-03 22:14:37 +08:00
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace MultiWheelC.TrajectoryPlanning.EMPlanner;
|
|
|
|
|
|
2026-08-11 20:32:31 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 验证规划契约中必须为有限数的标量输入。
|
|
|
|
|
/// </summary>
|
2026-08-03 22:14:37 +08:00
|
|
|
internal static class ContractNumeric
|
|
|
|
|
{
|
2026-08-11 20:32:31 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 拒绝 NaN 或无穷数值。<paramref name="value"/> 的单位由调用方语境决定;<paramref name="parameterName"/> 原样传给异常构造器,方法本身不验证它。
|
|
|
|
|
/// </summary>
|
2026-08-03 22:14:37 +08:00
|
|
|
public static void RequireFinite(double value, string parameterName)
|
|
|
|
|
{
|
|
|
|
|
if (double.IsNaN(value) || double.IsInfinity(value))
|
|
|
|
|
throw new ArgumentOutOfRangeException(parameterName, "A finite value is required.");
|
|
|
|
|
}
|
|
|
|
|
}
|