Results 1 to 4 of 4

Thread: location in a circle

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Location
    Minnesota
    Posts
    86

    location in a circle

    I am writing a program to do single plane balancing using the vector method. I am trying to compare two locations in a circle. An initial and a trial location. What I need to do is, compare the relationship between the two and decide which way from the trial location is. If the initial location is at 90. 270 is 180 from it. And if the trial would fall on 260 it would be CW, 280 would be CCW. Which ever way the trial goes, it will never be more than 180 from the initial location. Is there an easy way to test the user inputs? I put this in the maths forum, but no is in there.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2001
    Location
    Calgary, Canada
    Posts
    453
    ***???? Okay, I might not be the brightest beacon in the harbour, but I don't understand what your asking. Could you please rephrase the question, and I'll try and answer it. thanks

    SD
    "I'd rather have a full bottle in front of me than a full frontal lobotomy!"

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    don't put everything on oneline either it makes it harder to read, why don't you separate it out and explain what variables the user has to enter etc?

    see...

  4. #4
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    LOL SD.. i think i get what he means. CW would be clockwise and CCW counter clockwise. If the entered details are simply angles on a circle then it is pretty easy. It can be a little more complicated if the different positions are given by x,y coordinates but is still basically the same process.
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim Difference As Double
    3.     Dim Angle1 As Double 'These are degree angles
    4.     Dim Angle2 As Double 'Use Angle * pi / 180 for radians
    5.     Dim Direction As String
    6.    
    7.     Angle1 = Text1
    8.     Angle2 = Text2
    9.  
    10.     Difference = Angle2 - Angle1
    11.     If Difference > 180 Then
    12.         Difference = 360 - Angle2 + Angle1
    13.         Direction = "Counter Clockwise"
    14.     ElseIf Difference < -180 Then
    15.         Difference = 360 - Angle1 + Angle2
    16.         Direction = "Clockwise"
    17.     ElseIf Difference < 0 Then
    18.         Difference = Angle1 - Angle2
    19.         Direction = "Counter Clockwise"
    20.     Else
    21.         Direction = "Clockwise"
    22.     End If
    23.    
    24.     Debug.Print Direction, Difference
    25. End Sub
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

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