Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Need a little help with an angle problem.

Author
Message
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 5th Jun 2010 19:36 Edited at: 5th Jun 2010 19:36
I'm writing code for a targeting system, and it is sort of working, but it's got some odd behaviors that I can't quite figure out.

I have a target, on the left of the map below. The Red Circle shows it's actual position, and the Green Dot shows it's position according to the targeting system. All looks to be fine.

I have another target on the right side of the map below. Again, the Red Circle shows it's actual position, but the Green Dot is on the opposite side of the map. If I reverse the angle (360 - angle#) of course it shows it in the right place, but then it screws up the other target.

Here's the image.


and here's the code I'm using to point to it.


Something somewhere is obviously reversed, but I'm not seeing it for some reason.

paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 5th Jun 2010 19:46
Dont think it`s a problem with your code as such KISTech,more a problem with how ez_rotate returns it`s results,i had a similar problem with my rubiks cube code and im not sure exactly how i resolved it without going over to my machine at work,but i seem to think it was something to do with the results being in the range of -180 to +180 not 0 to 360 as you would imagine them to be.Not in work until monday but i`ll have a look for you then.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 5th Jun 2010 20:39 Edited at: 5th Jun 2010 20:47
That's true for the AXIS ANGLES commands, which is quite annoying, but this command actually returns 0-360.

The odd part about this is, along the X axis, the angle is right, but along the Y axis it's flipped.

[edit]

Ok, I figured it out. The image in the first post explains it all.

Up and to the left in a left-handed coordinate system would be -X, +Y. My Y axis is opposite that.

paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 5th Jun 2010 21:12 Edited at: 5th Jun 2010 21:15
Seems to work ok for me KISTech if this is the result you were after.I have used your code in a loop that repositions the object "target" at random and positions the object "dummytarget" at a fixed radius inline with it and it always seems to match up.

Im using your code with very few alterations to find the position for the "dummytarget" so i cant see why your geting strange angles returned.
Edit:
you beet me to it and posted while i was testing this.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 5th Jun 2010 22:04
Luckily all it took was reversing the values of an inner for next loop at the beginning of the program, and that fixed it. Map Y values rotated 90 degrees, but no other changes were necessary. (thankfully)

Login to post a reply

Server time is: 2026-07-25 16:20:10
Your offset time is: 2026-07-25 16:20:10