using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Island.StandardLib.Math
{
///
/// 提供一个参数化的非线性周期函数拟合
///
public class NonlinearPeriodicFunc
{
const double PI2 = 6.2831853071795862;
///
/// 最低值 (x=周期点)
///
public float Low { get; set; }
///
/// 最高值 (x=周期中点)
///
public float High { get; set; }
///
/// 周期长度
///
public float Length { get; set; }
public NonlinearPeriodicFunc(float low, float high, float length)
{
Low = low;
High = high;
Length = length;
}
public float f(float inputx)
{
return (float)(-System.Math.Cos(PI2 * inputx / Length) + 1) * ((High - Low) * 0.5f) + Low;
}
}
}