/// <summary> /// 由施工里程计算高程 /// </summary> /// <param name="listVC">初始化后的竖曲线要素</param> /// <param name="unityMileage">里程</param> /// <returns>高程</returns> public static double GetHeightByMileage(List <VerticalCurve> listVC, List <RuptureChain> listRC, double consMile) { double height = 0; //获得统一里程 double unityMileage = DataManagement.GetUnityMileage(listRC, consMile); bool b = false; //是否精确计算 int n; if (b) { //精确计算 n = GetPosition(listVC, unityMileage); } else { //常用计算 n = GetPositionCom(listVC, unityMileage); } if (n < 0 || n >= listVC.Count) { height = 0; } else { VerticalCurve vc = listVC[n]; //精确或常用计算 height = b ? AccurateHeight(vc, unityMileage) : CommonHeight(vc, unityMileage); } return(height); }
/// <summary> /// 精确计算高程 /// </summary> /// <param name="vc">变坡点</param> /// <param name="unityMileage">统一里程</param> /// <returns>高程</returns> public static double AccurateHeight(VerticalCurve vc, double unityMileage) { double height = 0; double l2 = vc.VarslopeUnity + vc.K2; if (l2 <= unityMileage) { height = vc.Height + (unityMileage - vc.VarslopeUnity) * vc.I2; } else { double d = vc.L - unityMileage; double dh = Math.Sqrt(Math.Pow(vc.R, 2) - Math.Pow(d, 2)); height = vc.H0 + dh * vc.Type; } return(height); }
//获取竖曲线要素 public static List <VerticalCurve> GetVerticalCurvePara() { try { MySqlOperating db = new MySqlOperating(); string sql = "select id,num,varslope_cons,varslope_uni,varslope_cons,h,r from jz_para_verticalcurve"; DataSet ds = db.GetDataSet(sql); if (ds != null) { List <VerticalCurve> listVC = new List <VerticalCurve>(); foreach (DataRow row in ds.Tables[0].Rows) { VerticalCurve vc = new VerticalCurve(); vc.Id = Convert.ToInt32(row["id"] == DBNull.Value ? 0 : row["id"]); vc.Num = Convert.ToInt32(row["num"] == DBNull.Value ? 0 : row["num"]); vc.VarslopeCons = Convert.ToDouble(row["varslope_cons"] == DBNull.Value ? 0 : row["varslope_cons"]); vc.VarslopeUnity = Convert.ToDouble(row["varslope_uni"] == DBNull.Value ? 0 : row["varslope_uni"]); vc.Height = Convert.ToDouble(row["h"] == DBNull.Value ? 0 : row["h"]); vc.R = Convert.ToDouble(row["r"] == DBNull.Value ? 0 : row["r"]); //剔除非变坡点 //if (vc.R>=0) //{ // listVC.Add(vc); //} listVC.Add(vc); } db.Close(); return(listVC); } else { db.Close(); return(null); } } catch (Exception e) { Console.WriteLine("GetVerticalCurvePara:" + e.Message); return(null); } }
/// <summary> /// 常用计算高程 /// </summary> /// <param name="vc">变坡点</param> /// <param name="unityMileage">统一里程</param> /// <returns>高程</returns> public static double CommonHeight(VerticalCurve vc, double unityMileage) { double height = 0; double l2 = vc.VarslopeUnity + vc.T1; if (l2 <= unityMileage) { height = vc.Height + (unityMileage - vc.VarslopeUnity) * vc.I2; } else if (vc.VarslopeUnity <= unityMileage) { double h = vc.Height - (vc.VarslopeUnity - unityMileage) * vc.I2; double dh = Math.Pow(unityMileage - l2, 2) / 2 / vc.R; height = h - dh * vc.Type; } else { double h = vc.Height - (vc.VarslopeUnity - unityMileage) * vc.I1; double dh = Math.Pow(unityMileage - vc.VarslopeUnity + vc.T1, 2) / 2 / vc.R; height = h - dh * vc.Type; } return(height); }
/// <summary> /// 竖曲线初始化 /// </summary> /// <param name="listVC">竖曲线要素</param> /// <returns>是否初始化完成</returns> public static bool InitializeVC(ref List <VerticalCurve> listVC) { if (listVC != null) { int len = listVC.Count; //计算方位角 for (int i = 0; i < len - 1; i++) { VerticalCurve vc = listVC[i + 1]; if ((vc.VarslopeUnity - listVC[i].VarslopeUnity) == 0) { continue; //断链点(里程一样) 为0 } double d = (vc.Height - listVC[i].Height) / (vc.VarslopeUnity - listVC[i].VarslopeUnity); if (Math.Abs(d) > 1) { return(false); } listVC[i].I2 = listVC[i + 1].I1 = d; listVC[i].A2 = listVC[i + 1].A1 = Math.Atan(d); } #region 计算 for (int i = 1; i < len - 1; i++) { //精确计算圆心角,切线长,竖曲线类型等 double a = listVC[i].A2 - listVC[i].A1; listVC[i].Alpha = Math.Abs(a); listVC[i].Type = a >= 0 ? -1 : 1; if (listVC[i].R == 0) { listVC[i].T = 0; //常用计算 listVC[i].E = 0; } else { listVC[i].T = listVC[i].R * Math.Tan(listVC[i].Alpha / 2); //常用计算 listVC[i].E = Math.Pow(listVC[i].T1, 2) / (2 * listVC[i].R); } listVC[i].K1 = listVC[i].T * Math.Cos(listVC[i].A1); listVC[i].K2 = listVC[i].T * Math.Cos(listVC[i].A2); listVC[i].H1 = listVC[i].Height - listVC[i].T * Math.Sin(listVC[i].A1); listVC[i].H2 = listVC[i].Height + listVC[i].T * Math.Sin(listVC[i].A2); listVC[i].H0 = listVC[i].H1 - listVC[i].Type * listVC[i].R * Math.Cos(listVC[i].A1); listVC[i].L = listVC[i].VarslopeUnity - listVC[i].K1 + listVC[i].Type * listVC[i].R * Math.Sin(listVC[i].A1); //常用计算 listVC[i].W = listVC[i].I2 - listVC[i].I1; listVC[i].Line = Math.Abs(listVC[i].W) * listVC[i].R; listVC[i].T1 = listVC[i].Line / 2; } #endregion return(true); } else { return(false); } }