MFC之畫圓弧 任意三點繪製圓弧求弧長

2021-08-06 00:01:03 字數 907 閱讀 5521

1. 先求出線的方向角(用向量)

// 得到兩點的角度 

// 0 - 360 以 point1 為圓心繞一周

double getanglefromtwopoint(cpoint point1, cpoint point2)

{ double angle = 0;

cpoint o = point1; //以第一點為圓心旋轉

cpoint a = point2;

double r = getthereallengthoftheline(o, a, false); //這只是求兩點間距離很簡單的我就不貼了

cpoint b = cpoint(o.x + r, o.y); //以圓心o為起點 o點右側距離r個畫素長度做b點(o->b)

cpoint oa = cpoint(a.x - o.x, a.y - o.y); //向量oa o->a

cpoint ob = cpoint(b.x - o.x, b.y - o.y); //向量ob o->b

double sin = (oa.x * ob.y - ob.x * oa.y) / (r * r); // |oa| = |ob| = r

angle = asin(sin); //弧度 asin(c) = (asin(c) * (180.0 / pi))

if (o.x < a.x && o.y > a.y)  //象限1

angle = angle;

else if (o.x > a.x && o.y > a.y) //象限2

angle = 180 - angle;

else if (o.x > a.x && o.y < a.y) //象限3

angle = 180 - angle;

else if (o.x <

UIBezierPath畫圓弧的記錄

uibezierpath通過 void addarcwithcenter cgpoint center radius cgfloat radius startangle cgfloat startangle endangle cgfloat endangle clockwise bool clock...

UIBezierPath 畫圓弧(角度問題)

uibezierpath通過 void addarcwithcenter cgpoint center radius cgfloat radius startangle cgfloat startangle endangle cgfloat endangle clockwise bool clock...

UIBezierPath畫圓弧的記錄

文中的圖很重要!根據下文,完成了下圖的mask 如下 cgsize size self.size 畫路徑 uibezierpath maskpath uibezierpath bezierpath bottom line maskpath movetopoint cgpointmake size.w...