www.pudn.com > BackscatterMap.rar > calculate.cs, change:2009-08-04,size:9052b
using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Collections; using System.Collections.Generic; using System.Windows.Forms; using System.Text; using System.Data.SqlTypes; using System.IO; namespace WindowsApplication4 { //此类主要计算每个杂波单元的俯角、 class calculate { shadowing myshadowing = new shadowing(); public double[,] elevation; //存储每个节点的高程 public double[,] nodeEle; //存储极坐标每个节点的高程 public double[,] centerPointEle; //存储每个扇区中心点的高程 public bool[,] sign; //--------雷达和地形的参数---------------------- int radarX; int radarZ; double radarHeight; int rowNum; int colNum; double unit; double interval; double theta; //-------------------------------------------------- public calculate() { elevation = shadowing.elevation; centerPointEle = myshadowing.polaCoord(); sign = myshadowing.shadow(); radarX = shadowing.radarX; radarZ = shadowing.radarZ; radarHeight = shadowing.radarHeight; rowNum = shadowing.rowNum; colNum = shadowing.colNum; unit = shadowing.unit; interval = shadowing.interval; theta = 2 * Math.PI / rowNum; //theta为分割同心圆的角度 } public struct dPoint { public double x; public double z; } public dPoint[,] point; //用于计算每个扇区节点的X,Z轴坐标值 public dPoint[,] point1; //用于存储每个扇区中心点X,Z轴坐标值 public dPoint[,] point2; //计算平均高程 public double[,] calAveEle() { nodeEle = new double[rowNum, colNum]; point = new dPoint[rowNum, colNum]; double[,] aveEle = new double[rowNum, colNum]; //计算每个扇区节点的X,Z坐标值 for (int i = 0; i < rowNum; i++) { double temp1 = interval * Math.Cos(i * theta); double temp2 = interval * Math.Sin(i * theta); double temp3 = interval * Math.Cos(i * theta) + radarX * unit; double temp4 = interval * Math.Sin(i * theta) + radarZ * unit; for (int j = 0; j < colNum; j++) { point[i, j].x = temp3; point[i, j].z = temp4; temp3 = temp3 + temp1; temp4 = temp4 + temp2; } } //插值获得每个扇区节点的高程值 for (int i = 0; i < rowNum; i++) { for (int j = 0; j < colNum; j++) { nodeEle[i, j] = myshadowing.interpolate(point[i, j].x, point[i, j].z); } } for (int i = 0; i < rowNum; i++) { int m; Math.DivRem(i + 1, rowNum, out m); aveEle[i, 0] = (radarHeight + nodeEle[i, 0] + nodeEle[m, 0]) / 3; } //--------------------------------------------------- for (int i = 0; i < rowNum; i++) { for (int j = 1; j < colNum; j++) { if (sign[i, j] == true) aveEle[i, j] = 0; else { int m; Math.DivRem(i + 1, rowNum, out m); aveEle[i, j] = (nodeEle[i, j - 1] + nodeEle[i, j] + nodeEle[m, j - 1] + nodeEle[m, j]) / 4; } } } return aveEle; } //计算当地入射角 public double[,] calIncidenceAngel() { point1 = new dPoint[rowNum, colNum]; point2 = new dPoint[rowNum, colNum]; double[,] yWeight = new double[rowNum, colNum]; double[,] inciAngle = new double[rowNum, colNum]; for (int i = 0; i < rowNum; i++) { double temp1 = interval * Math.Cos((i + 0.5) * theta); double temp2 = interval * Math.Sin((i + 0.5) * theta); double temp3 = interval * 0.5 * Math.Cos((i + 0.5) * theta) ; double temp4 = interval * 0.5 * Math.Sin((i + 0.5) * theta) ; for (int j = 0; j < colNum; j++) { point1[i, j].x = temp3; point1[i, j].z = temp4; temp3 = temp3 + temp1; temp4 = temp4 + temp2; } } for (int i = 0; i < rowNum; i++) { double temp1 = interval * Math.Cos(i * theta); double temp2 = interval * Math.Sin(i * theta); double temp3 = interval * Math.Cos(i * theta); double temp4 = interval * Math.Sin(i * theta); for (int j = 0; j < colNum; j++) { point2[i, j].x = temp3; point2[i, j].z = temp4; temp3 = temp3 + temp1; temp4 = temp4 + temp2; } } for (int i = 0; i < rowNum;i++ ) { if (sign[i, 0] == true) { yWeight[i, 0] = 0; inciAngle[i, 0] = 0; } else { yWeight[i, 0] = centerPointEle[i, 0] - radarHeight; double temp = Math.Sqrt(Math.Pow(point1[i, 0].x, 2) + Math.Pow(point1[i, 0].z, 2) + Math.Pow(yWeight[i, 0], 2)); double x = point1[i, 0].x / temp; double z = point1[i, 0].z / temp; double y = yWeight[i, 0] / temp; int m; Math.DivRem(i+1,rowNum,out m); double fz =point2[i,0].x*(nodeEle[m,0]-radarHeight)-point2[m,0].x*(nodeEle[i,0]-radarHeight); double fx =point2[m,0].z*(nodeEle[i,0]-radarHeight)-point2[i,0].z*(nodeEle[m,0]-radarHeight); double fy = point2[m, 0].x * point2[i, 0].z - point2[i, 0].x * point2[m, 0].z; double R = Math.Sqrt(Math.Pow(fx, 2) + Math.Pow(fy, 2) + Math.Pow(fz, 2)); fx = fx / R; fy = fy / R; fz = fz / R; double dot = x * fx + z * fz + y * fy; inciAngle[i, 0] = Math.Asin(Math.Abs(dot)); } } //----------------------------------------------- for (int i = 0; i < rowNum;i++ ) { for (int j = 1; j < colNum;j++ ) { if (sign[i, j] == true) { yWeight[i, j] = 0; inciAngle[i, j] = 0; } else { yWeight[i, j] = centerPointEle[i, j] - radarHeight; double temp = Math.Sqrt(Math.Pow(point1[i, j].x, 2) + Math.Pow(point1[i, j].z, 2) + Math.Pow(yWeight[i, j], 2)); double x = point1[i, j].x / temp; double z = point1[i, j].z / temp; double y = yWeight[i, j] / temp; dPoint tempPoint = new dPoint(); tempPoint.x = interval * j * Math.Cos((i + 0.5) * theta) + radarX * unit; tempPoint.z = interval * j * Math.Sin((i + 0.5) * theta) + radarX * unit; double tempEle = myshadowing.interpolate(tempPoint.x, tempPoint.z); int m; Math.DivRem(i + 1, rowNum, out m); double fz = (point2[i, j].x - tempPoint.x) * (nodeEle[m, j] - tempEle) - (point2[m, j].x - tempPoint.x) * (nodeEle[i, j] - tempEle); double fx = (point2[m, j].z - tempPoint.z) * (nodeEle[i, j] - tempEle) - (point2[i, j].z - tempPoint.z) * (nodeEle[m, j] - tempEle); double fy = (point2[m, j].x - tempPoint.x) * (point2[i, j].z - tempPoint.z) - (point2[i, j].x - tempPoint.x) * (point2[m, j].z - tempPoint.z); double R = Math.Sqrt(Math.Pow(fx, 2) + Math.Pow(fy, 2) + Math.Pow(fz, 2)); fx = fx / R; fy = fy / R; fz = fz / R; double dot = x * fx + z * fz + y * fz; inciAngle[i, j] = Math.Asin(Math.Abs(dot)); } } } return inciAngle; } } }