private function getcenof3pt(pt1 as variant, pt2 as variant, pt3 as variant, byref radius as double) as variant
''''根據三點計算出圓心和半徑
dim xysm, xyse, xy as double
dim ptcen(2) as double
xy = pt1(0) ^ 2 + pt1(1) ^ 2
xyse = xy - pt3(0) ^ 2 - pt3(1) ^ 2
xysm = xy - pt2(0) ^ 2 - pt2(1) ^ 2
xy = (pt1(0) - pt2(0)) * (pt1(1) - pt3(1)) - (pt1(0) - pt3(0)) * (pt1(1) - pt2(1))
'''判斷引數有效性
if abs(xy) < 0.000001 then
msgbox "所輸入的引數無法建立圓形!"
exit function
end if
'獲得圓心和半徑
ptcen(0) = (xysm * (pt1(1) - pt3(1)) - xyse * (pt1(1) - pt2(1))) / (2 * xy)
ptcen(1) = (xyse * (pt1(0) - pt2(0)) - xysm * (pt1(0) - pt3(0))) / (2 * xy)
ptcen(2) = 0
radius = sqr((pt1(0) - ptcen(0)) * (pt1(0) - ptcen(0)) + (pt1(1) - ptcen(1)) * (pt1(1) - ptcen(1)))
if radius < 0.000001 then
msgbox "半徑過小!"
exit function
end if
''函式返回圓心的位置,而半徑則在引數中通過引用方式返回
getcenof3pt = ptcen
end function
public function addarc3pt(byval ptst as variant, byval ptsc as variant, byval pten as variant) as acadarc
''''三點法建立圓弧
dim objarc as acadarc
dim ptcen as variant
dim radius as double
ptcen = getcenof3pt(ptst, ptsc, pten, radius)
if isclockwise(ptcen, ptst, ptsc, pten) then
set objarc = addarccsep(ptcen, ptst, pten)
else
set objarc = addarccsep(ptcen, pten, ptst)
end if
objarc.update
set addarc3pt = objarc
end function
private function addarccsep(byval ptcen as variant, byval ptst as variant, byval pten as variant) as acadarc
dim objarc as acadarc
dim radius as double
dim stang, enang as double
''計算半徑
radius = getdistance(ptcen, ptst)
''計算起點角度和終點角度
stang = thisdrawing.utility.anglefromxaxis(ptcen, ptst)
enang = thisdrawing.utility.anglefromxaxis(ptcen, pten)
set objarc = thisdrawing.modelspace.addarc(ptcen, radius, stang, enang)
objarc.update
set addarccsep = objarc
end function
'判斷三點的方向
function isclockwise(ptcen, ptst, ptsc, pten) as boolean
a1 = thisdrawing.utility.anglefromxaxis(ptcen, ptst)
a2 = thisdrawing.utility.anglefromxaxis(ptcen, ptsc)
a3 = thisdrawing.utility.anglefromxaxis(ptcen, pten)
isclockwise = (a1 < a2) xor (a2 < a3) xor (a1 < a3)
end function
三點法求三維座標精度誤差評估實驗
1 對實驗做乙個系統性的誤差評價。2 驗證本實驗的精度能否達到測量空間角的要求。2 實驗原理 參考 1 進行誤差評估實驗,但是由於 中的評定指標並不都適合本次實驗,所以要重新考慮哪些變數可以作為判斷三點法求三維座標是否精確的指標,哪些不能。經過可操作性等考慮之後,選取了3 維中的距離和空間角作為指標...
MFC之畫圓弧 任意三點繪製圓弧求弧長
1.先求出線的方向角 用向量 得到兩點的角度 0 360 以 point1 為圓心繞一周 double getanglefromtwopoint cpoint point1,cpoint point2 double angle 0 cpoint o point1 以第一點為圓心旋轉 cpoint a...
三點定位法原理及實現 藍芽定位
實現 最近在做藍芽室內定位,藍芽定位用到的乙個非常經典的演算法就是三點定位法。三點定位法,顧名思義首先有三個圓點,同時我們也知道這三個圓的半徑,最終求得三圓的交點,達到定位效果。如圖 我們的目的是求得o點,利用畢達哥拉斯定理我們可以快速求得o點座標。不過事與願違,現實情況並不總是如人意,而是這樣 甚...