Help me out here- do angles that go from 0 to 6.28 go clockwise or counter-clockwise in vb? It seems to be backwards from traditional math. Were my teachers on crack? You tell me. Any other info on the subject is greatly appreciated.
Printable View
Help me out here- do angles that go from 0 to 6.28 go clockwise or counter-clockwise in vb? It seems to be backwards from traditional math. Were my teachers on crack? You tell me. Any other info on the subject is greatly appreciated.
There is no real orientation to the angles if you want to be technical about it, since you can define your own reference. You can see it though if you have something rotating based on some trig. It's because of how the coordinate system of a window is done, with down being the positive y axis rather than the negative one, so quadrants I and II are flipped with III and IV. In that regard though, it will appear to be clockwise. VB does use the standard reference in how it "starts" out though, by anchoring angles to the positive x axis. If you want to see what I'm talking about, put this into a project. It's just a line that will move like a clock hand. As the angle increases from 0, you'll see it move clockwise. The line starts in the standard position. You can just stick the line anywhere on the form, but give it room to rotate around. The end at X2,Y2 is the end that will be fixed, and X1,Y1 will be moving. The line is named linLine, and you need a timer named tmrRotate. Click on the form to start/stop the timer.
Isn't trig lovely :).VB Code:
Option Explicit Const Pi As Double = 3.14159265358979 Dim dblLength As Double Dim dblAngle As Double Private Sub Form_Click() tmrRotate.Enabled = Not tmrRotate.Enabled End Sub Private Sub Form_Load() Me.ScaleMode = vbPixels tmrRotate.Interval = 100 With linLine 'this is just the length of the line, from the distance formula you're most likely familiar with dblLength = Sqr(((.X2 - .X1) ^ 2) + ((.Y2 - .Y1) ^ 2)) End With End Sub Private Sub tmrRotate_Timer() dblAngle = dblAngle + ((2 * Pi) / 360) With linLine .X1 = .X2 + (dblLength * Cos(dblAngle)) .Y1 = .Y2 + (dblLength * Sin(dblAngle)) End With End Sub
Thank you thank you thank you! It makes such perfect sense now. I didn't even think about the fact that since the origin had been moved up they would flip the quadrants. I'm off now to fix my program. You are my savior oh wise one! Gracias!
Trig is my buddy :cool: It took me a while to figure this out on my own back when I first encountered it too. I thought I was going nuts because the sacred reference seemed to be discarded :).