tangxu
2024-10-09 b1cee427f6383b243b8c0aa45aabce9f58075d8d
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
128
129
130
131
132
133
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
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.CurveExpress = rhs.CurveExpress;
        }
        //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 _curveExpress = null;
        public Yw.Geometry.CubicSpline2d CurveExpress { get { return _curveExpress; } set { _curveExpress = 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 equipCurveZeroH = OriginPoints[0].Y;
            var endPt = OriginPoints[1];
            List<Yw.Geometry.Point2d> points = new List<Yw.Geometry.Point2d>();
            double k = (endPt.Y - equipCurveZeroH) / (endPt.X * endPt.X);
            double minQ = 0;
            double maxQ = endPt.X;
            double space = (maxQ - minQ) / (fitPointNum - 1);//11个点
            for (int i = 0; i < fitPointNum; i++)
            {
                double x = space * i + minQ;
                double y = k * x * x + equipCurveZeroH;
                points.Add(new Yw.Geometry.Point2d(x, y));
            }
 
            this.CurveInfo = points;
            this.CurveExpress = new CubicSpline2d(points);
        }
 
        public double ParabolaCoeff
        {
            get
            {
                if (OriginPoints == null || OriginPoints.Count != 2)
                    return 0;
 
                double equipCurveZeroH = OriginPoints[0].Y;
                var endPt = OriginPoints[1];
                List<Yw.Geometry.Point2d> points = new List<Yw.Geometry.Point2d>();
                return (endPt.Y - equipCurveZeroH) / (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 equipCurveZeroH = OriginPoints[0].Y;
            var endPt = OriginPoints[1];
            List<Yw.Geometry.Point2d> points = new List<Yw.Geometry.Point2d>();
            double k = (endPt.Y - equipCurveZeroH) / (endPt.X * endPt.X);
            double minQ = 0;
            if (minY > equipCurveZeroH)
                minQ = Math.Sqrt((minY - equipCurveZeroH) / k);
            double maxQ = endPt.X;
            double space = (maxQ - minQ) / (fitPointNum - 1);
            for (int i = 0; i < fitPointNum; i++)
            {
                double x = space * i + minQ;
                double y = k * x * x + equipCurveZeroH;
                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
    }
}