Shuxia Ning
2025-01-03 5e776f1884d4d865c8d3d037a1fb10fb083f37ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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]; 
                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
    }
}