具体要求:在屏幕上用鼠标输入三个点,按输入点的顺序画弧.求算术.
解决方案 »
- InitInstance函数处理OnOk//怎么不行呢?
- 请教一个关于双缓冲绘图的问题?
- MSDN怎么安装?
- link连接,错误,(already defined )在线等。
- 高分请教(100)如何修改下面的函数,不使用MFC类
- 怎么把另外一个工程中的dlg资源上的控件粘贴过来??
- 关于WSAResetEvent的简单问题 :)
- 关于CRgn的区域问题?
- 如何从一个类中获得另一类的成员变量的值
- 这个用C++实现的小型web服务器可以接收浏览器的请求,但是无法把内容发送到浏览器
- 书上说,线程分为工作者线程与 UI 线程. 工作者线程见得多了. 但, 怎样编写一个 UI 线程信相应的执行函数 ?
- 什么情况下用bezier(贝塞尔)曲面求值,什么情况用nurbs(非均匀有理B样条曲面)?
this is vb code, u can use this to calc the radius and focus of the ellipse :)
:)
instead the custom data-type( such as CPOINT, CCIRCLE ) with struct ok.
:)
'==========================
'==名称:TPC
'==功能:解决三点求圆问题
'==参数:P1,P2,P3---已知的三个点
'==返回:待求的圆
'==========================
Public Function TPC(ByVal P1 As CPOINT, ByVal P2 As CPOINT, ByVal P3 As CPOINT) As CCIRCLE
On Error GoTo ErrHandle
Dim a As Double, b As Double, E As Double
Dim T As New CCIRCLE
a = (P1.X + P2.X) * (P1.X - P2.X) + (P1.Y + P2.Y) * (P1.Y - P2.Y)
b = (P3.X + P2.X) * (P3.X - P2.X) + (P3.Y + P2.Y) * (P3.Y - P2.Y)
E = (P1.X - P2.X) * (P3.Y - P2.Y) - (P2.X - P3.X) * (P2.Y - P1.Y)
T.cx = (a * (P3.Y - P2.Y) + b * (P2.Y - P1.Y)) / (2 * E)
T.cy = (a * (P2.X - P3.X) + b * (P1.X - P2.X)) / (2 * E)
T.R = Sqr((P1.X - T.cx) ^ 2 + (P1.Y - T.cy) ^ 2)
Set TPC = T
Exit Function
ErrHandle:
MsgBox "常用计算工具提示--" & lf & "三点求圆--你输入的数据有错误", vbOKOnly Or vbCritical, "CRT CADC"
Err = 0
End Function
'==========================
'==名称:IsInALine
'==功能:预览三点求圆问题
'==参数:P1,P2,P3---已知的三个点
'==返回:是否合理 True---合理、False---不合理
'==========================
Public Function IsInALine(ByVal P1 As CPOINT, ByVal P2 As CPOINT, ByVal P3 As CPOINT) As String
IsInALine = "OK"
Dim a As Double, b As Double, E As Double
a = (P1.X + P2.X) * (P1.X - P2.X) + (P1.Y + P2.Y) * (P1.Y - P2.Y)
b = (P3.X + P2.X) * (P3.X - P2.X) + (P3.Y + P2.Y) * (P3.Y - P2.Y)
E = (P1.X - P2.X) * (P3.Y - P2.Y) - (P2.X - P3.X) * (P2.Y - P1.Y)
If Abs(E - 0) < 0.0000001 Then
IsInALine = "过此三点不能求圆" & lf & "请检查输入数据"
End If
End Function
用Arc画弧即可