具体要求:在屏幕上用鼠标输入三个点,按输入点的顺序画弧.求算术.

解决方案 »

  1.   

    hehe, see this, don't forget, it's JennyVenus first post this
    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
      

  2.   

    保存3个鼠标单击点
    用Arc画弧即可