vb.netgeometric-arc

How to draw circular arcs in VB.NET


I have to generate the following figure according to user fed values. How do I go about drawing the arcs (B-C-F as in figure, circular in nature) given their start point & end point (B & F respectively) & the height from the segment BF? I can do some geometric calculations & get the radius & all, but how do I draw the arc?

enter image description here

I have tried using the Graphics.DrawCurve() method, but it doesn't work as expected. How can I make this method work for circular arcs? Any other workaround is also welcome.


Solution

  • Got it! Thanks @Mitch & @Idle_Mind

    Using the builtin DrawArc method of Graphics

    Friend Function draw_tank() As Boolean
    
        ' Create pen. 
        Dim blackPen As New Pen(Color.Black, 3)
    
        ' Create rectangle to bound ellipse. 
        Dim rect As New Rectangle(100, 100, 200, 200)
        ' Keeping the width & length same (200) we get a circle
    
        ' Create start and sweep angles on ellipse. 
        Dim startAngle As Single = 225.0F
        Dim sweepAngle As Single = 90.0F
    
        ' Draw arc to screen.
        Dim myarc As Graphics = Me.CreateGraphics
        myarc.DrawArc(blackPen, rect, startAngle, sweepAngle)
    
        Return True
    End Function
    

    Suggestions/Improvements welcome.

    Note - This isn't the actual function from my code.