Home > Net >  CAD secondary development in circular uniform source code
CAD secondary development in circular uniform source code

Time:09-15

Because in CAD secondary development, the circular arc of StartAngle EndAngle and attribute from the range of 0 to 2 PI, so yes forever will only use formula to calculate directly to counterclockwise from the perspective of small to large Angle between the points, the other is unable to calculate a (details too difficult to describe, can try ), the source code by Angle and StartAngle, EndAngle difference judgment belongs to which side of the arc, so as to solve the problem, if there is a more simple way to please the great god give directions
 private List{

ListPoint3d center=arc. The center;
Double radius=arc. The radius;
Double startAngle=arc. StartAngle;
Double endAngle=arc. EndAngle;
Double totalAngel=arc. TotalAngle;
Double startToEndAngel=Math. Abs (endAngle - startAngle);
If (startToEndAngel!=totalAngel & amp; & TotalAngel!=Math. PI)
{
StartAngle -=2 * Math. PI;
}
Else if (totalAngel==math.h PI & amp; & StartAngle & gt; EndAngle)
{
StartAngle -=2 * Math. PI;
}
Int numberOfPolylineSegment=100;
Double step=(endAngle - startAngle)/numberOfPolylineSegment;
for (int i=0; i <=numberOfPolylineSegment; I++)
{
Point2d pt=new Point2d (center) radius, X + * Math) Cos (I * step + startAngle), center, radius, Y + * math.h Sin (I * step + startAngle));
PointList. Add (pt);
}
Return pointList;
}
  •  Tags:  
  • C#
  • Related