//精确角度绘制副区 public List <Point3D> DrawAccruateOffset(double offSet = 0, double step = 1) { //绘制指定θ角范围的风螺旋线,所有参数均为 弧度数。 double sita = startSita; Point3D p1 = GetTangentPoint(startSita); Point3D p2 = p1.Add(WindSpirlTool.Polar(offSet, startSita - _DA)); //建立点串 List <Point3D> points = new List <Point3D>(); points.Add(p2); Point3D OffsetStartPoint = new Point3D(); OffsetStartPoint.X = p2.X; OffsetStartPoint.Y = p2.Y; while (sita < endSita) { sita += step * Math.PI / 180; p1 = GetTangentPoint(sita); p2 = p1.Add(WindSpirlTool.Polar(offSet, sita - _DA)); points.Add(p2); } p1 = GetTangentPoint(endSita); Point3D OffsetEndPoint = new Point3D(); OffsetEndPoint = p1.Add(WindSpirlTool.Polar(offSet, endSita - _DA)); points.Add(OffsetEndPoint); return(points); }
//根据线外点 pointB,求过该点的风螺旋线切线的切点所对应的 sita 角 public double GetTangentSita(Point3D pointB) { //输入风螺旋线外点,求过该点的切线对应的sita角度(单位:弧度) //圆心点C,线外点B,圆弧上的切点A,螺旋线上的切点D Point3D pointC = new Point3D(0, 0);//圆心默认位置 double dist = WindSpirlTool.Distance(pointB, pointC); //atan2 函数具有指向性,但常出现负值,需要转换处理。 double alfa = Math.Atan2(pointB.Y - pointC.Y, pointB.X - pointC.X); alfa = (alfa + 2 * Math.PI) % (2 * Math.PI);//转换成正值 double beta = Math.Acos((_r / dist)); double sita = alfa - beta; //check distance of B is out of the windspiral //用 getSpiralPoint 函数来检测 Point3D tempPt = GetTangentPoint(GetSita(alfa)); if (dist < WindSpirlTool.Distance(tempPt, pointC)) { throw new Exception("The distance of L is too short. Please enlarge the outbound time."); } //the tangent point of Norminal Track Point3D p = WindSpirlTool.Polar(_r, sita); Point3D pointA = pointC.Add(p); //add //the initial tangent point of Wind Spiral p = WindSpirlTool.Polar((_esita * sita), sita - _DA); Point3D pointD = pointA.Add(p); //add double calcuSita = Math.Atan2(pointB.Y - pointD.Y, pointB.X - pointD.X); calcuSita = (calcuSita + 2 * Math.PI) % (2 * Math.PI);//转换成正值 double tolerance = calcuSita - ((sita - _DA) + Math.PI / 2); double j = 0; while (tolerance > 0.0000001) { sita += tolerance; p = WindSpirlTool.Polar(_r, sita); pointA = pointC.Add(p); //add p = WindSpirlTool.Polar((_esita * sita), sita - _DA); pointD = pointA.Add(p); //add calcuSita = Math.Atan2(pointB.Y - pointD.Y, pointB.X - pointD.X); calcuSita = (calcuSita + 2 * Math.PI) % (2 * Math.PI);//转换成正值 tolerance = calcuSita - sita + _DA - Math.PI / 2; //trace( newMinus ); j += 1; } return(sita); }