namespace Yw.Geometry
|
{
|
public class EquipCurveParas : ICloneable
|
{
|
public EquipCurveParas() { }
|
//二次曲线
|
public EquipCurveParas(double zeroPointH, Yw.Geometry.Point2d endPoint, int fitPointNum = 12)
|
{
|
type = 0;
|
SetParabolaPoints(zeroPointH, endPoint);
|
ResetCurveInfo(fitPointNum);
|
}
|
|
public EquipCurveParas(EquipCurveParas rhs)
|
{
|
this.Type = rhs.type;
|
this.OriginPoints = rhs.OriginPoints;
|
this.CurveInfo = rhs.CurveInfo;
|
this.EquipCurve = rhs.EquipCurve;
|
}
|
//0表示二次曲线, 1表示手动输入
|
private int type = 0;
|
public int Type { get { return type; } set { type = value; } }
|
//手动输入时是输入的点,二次曲线是两个定义点
|
private List<Yw.Geometry.Point2d> _originPoints = null;
|
public List<Yw.Geometry.Point2d> OriginPoints { get { return _originPoints; } set { _originPoints = value; } }
|
//曲线上的点有可能根据坐标最小值,进行了切割
|
private List<Yw.Geometry.Point2d> _curveInfo = null;
|
public List<Yw.Geometry.Point2d> CurveInfo { get { return _curveInfo; } set { _curveInfo = value; } }
|
//曲线方程
|
public Yw.Geometry.CubicSpline2d _equipuip_curve = null;
|
public Yw.Geometry.CubicSpline2d EquipCurve { get { return _equipuip_curve; } set { _equipuip_curve = value; } }
|
|
//0流量点扬程
|
public double ZeroPointH { get { return OriginPoints[0].Y; } }
|
//设置抛物线点
|
public void SetParabolaPoints(double zeroPointH, Yw.Geometry.Point2d endPoint)
|
{
|
type = 0;
|
this.OriginPoints = new List<Yw.Geometry.Point2d>();
|
this.OriginPoints.Add(new Yw.Geometry.Point2d(0, zeroPointH));
|
this.OriginPoints.Add(endPoint);
|
}
|
//
|
public void ResetCurveInfo(int fitPointNum)
|
{
|
if (type != 0)
|
return;
|
|
if (OriginPoints == null || OriginPoints.Count != 2)
|
return;
|
|
double equipuipCurveZeroH = OriginPoints[0].Y;
|
var endPt = OriginPoints[1];
|
List<Yw.Geometry.Point2d> points = new List<Yw.Geometry.Point2d>();
|
double k = (endPt.Y - equipuipCurveZeroH) / (endPt.X * endPt.X);
|
double min_flow = 0;
|
double max_flow = endPt.X;
|
double space = (max_flow - min_flow) / (fitPointNum - 1);//11个点
|
for (int i = 0; i < fitPointNum; i++)
|
{
|
double x = space * i + min_flow;
|
double y = k * x * x + equipuipCurveZeroH;
|
points.Add(new Yw.Geometry.Point2d(x, y));
|
}
|
|
this.CurveInfo = points;
|
this.EquipCurve = new CubicSpline2d(points);
|
}
|
|
public double ParabolaCoeff
|
{
|
get
|
{
|
if (OriginPoints == null || OriginPoints.Count != 2)
|
return 0;
|
|
double equipuipCurveZeroH = OriginPoints[0].Y;
|
var endPt = OriginPoints[1];
|
List<Yw.Geometry.Point2d> points = new List<Yw.Geometry.Point2d>();
|
return (endPt.Y - equipuipCurveZeroH) / (endPt.X * endPt.X);
|
}
|
}
|
public void ResetCurveInfoByMinY(int fitPointNum, double minY)
|
{
|
if (type != 0)
|
return;
|
if (minY < 0.01)
|
{
|
ResetCurveInfo(fitPointNum);
|
return;
|
}
|
if (OriginPoints == null || OriginPoints.Count != 2)
|
return;
|
|
double equipuipCurveZeroH = OriginPoints[0].Y;
|
var endPt = OriginPoints[1];
|
List<Yw.Geometry.Point2d> points = new List<Yw.Geometry.Point2d>();
|
double k = (endPt.Y - equipuipCurveZeroH) / (endPt.X * endPt.X);
|
double min_flow = 0;
|
if (minY > equipuipCurveZeroH)
|
min_flow = Math.Sqrt((minY - equipuipCurveZeroH) / k);
|
double max_flow = endPt.X;
|
double space = (max_flow - min_flow) / (fitPointNum - 1);
|
for (int i = 0; i < fitPointNum; i++)
|
{
|
double x = space * i + min_flow;
|
double y = k * x * x + equipuipCurveZeroH;
|
points.Add(new Yw.Geometry.Point2d(x, y));
|
}
|
|
this.CurveInfo = points;
|
}
|
|
|
#region Clone
|
object ICloneable.Clone()
|
{
|
return Clone();
|
}
|
|
public EquipCurveParas Clone()
|
{
|
return new EquipCurveParas(this);
|
}
|
#endregion
|
}
|
}
|