Results 1 to 6 of 6

Thread: Arc Degrees

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2006
    Location
    Florida, USA
    Posts
    565

    Arc Degrees

    I tried all kinds of things to calculate the Arc degrees. And did lots of research. Anyways, I made a diagram and I will post my code attempt as well. Any assistance with the getDegreesArcText function would be great

    vb Code:
    1. Private Shared Function getDegreesArcText(g As Graphics, text As String, font As Font, circleRadius As Double) As Double
    2.         Dim degrees As Double
    3.         Dim linearSize As SizeF
    4.         linearSize = g.MeasureString(text, font)
    5.  
    6.         'TODO: use curved line to calculate
    7.         'Dim thePoint As Point = clsJoystickSlim.DegreesToPoint(New Point(0, 0), circleRadius, 10)
    8.         'Dim arcLineSize As Double = joystick.findAngle(New Point(0, 0), New Point(circleRadius, 0), New Point(circleRadius, linearSize.Width)) 'thePoint)
    9.  
    10.  
    11.         degrees = 'linearSize.Width
    12.         Return degrees
    13.     End Function
    14.  
    15.     Public Function findAngle(p1 As Point, p2 As Point, p3 As Point) As Double
    16.         Dim a_x As Double = p2.X - p1.X
    17.         Dim a_y As Double = p2.Y - p1.Y
    18.  
    19.         Dim b_x As Double = 1.0
    20.         Dim b_y As Double = 0.0
    21.  
    22.         Return Math.Acos((a_x * b_x + a_y * b_y) / Math.Sqrt(a_x * a_x + a_y * a_y))
    23.     End Function
    Attached Images Attached Images  
    Last edited by rex64; Nov 8th, 2011 at 03:21 PM. Reason: Image had a mistake on the coordinates.
    I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width