Angles and VERGE
Displaying 1-5 of 5 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
locke

EDIT [ Hm. Well, it seems like I might have figured out my drawing problem. I think it's completely unrelated. I have also (with some experimentation) answered my other generic questions about why it's OK that I'm subtracting from Y (duh, Y is inverted, or gets larger as it goes down). So no worries, really. But it might be nice for someone who knows all the details to write up a quick summary about all the little strangenesses I mentioned, and those that I don't know about (yet).]


So, I have an engine based on x,y coords, and everything works OK. Sort of. The vector thing is good, the angles seem to be working fine. I can MOVE around the coordinate system fine, but I have recently uncovered a very strange problem.

Before I go further, I'd like to say that I'm pretty sure it is a side effect of my lame-ass attempt at trying to work around VERGE's weirdo angle issues.

That said, when I first built the engine, my vector angles/directions didn't work out. After some research I read somewhere (now I can't find it) that VERGE's vector angles work backwards to the 'traditional' clockwise direction, and that 0 was at (traditionally) 90 degrees. I compensated, and my craft turned fine. That's easy to fix.

What isn't as easy is a problem that comes up when I'm calculating vectors. I think.

You see, when I'm done calculating the vectors, in order for me to get my ship to 'fly correctly', I must SUBTRACT the vectorized value from the current Y coordinate, rather than adding it, which is what one is supposed to do. I think.

But then I realized that that might be because our coordinate system is based on the lower right quadrant (0,0 being in upper left). But it still makes my head spin, and I know it's screwing something up.

I believe my drawing issues might be related to this ugly hack.

Can someone explain to me exactly what I need to know about how VERGE handles vectors differently than convention? Like, what is the deal with the angles? Do I have it right? And why do I need to subtract from the Y value after calculating a new vector, rather than (what I know to be the 'norm') adding?

The really screwed up thing is that it works perfectly, except for this wacking drawing issue. I'm only asking because I can't find a problem with my (very simple) drawing code... but since the drawing is based on the coordinate system, I'm thinking that it might be related.

Please pass the crack.

-l

Posted on 2004-10-07 19:53:23 (last edited on 2004-10-07 21:24:10)

mcgrue

Paging Dr Rector... Dr. Charles Rector to the Help Forum...

Posted on 2004-10-07 21:14:30

Omni

What I can tell you is that angles aren't really clockwise at all. Take a look at your friendly unit circle. Angles increment counter-clockwise.

Also, I'm not quite sure what you're trying to do. However, I have a feeling it has something to do with calculating angles from X and Y coordinates--like an ArcTan.

Right? Have you looked at the code for an ArcTan2 lately?


int OID_Atan2(int rise, int run) {
/*Rise is the y-delta, run is the x-delta. */
int t;
if (run == 0)
{
if (rise > 0) return 90;
if (rise < 0) return 270;
else return 0;
}
if (rise == 0)
{
if (run < 0) return 180;
else return 0;
}
t = atan((rise*65536)/run);

if (run > 0 && rise < 0) return t + 360;
if (run < 0) return t + 180;

return t;
}


This isn't commented at all, but anyway. It's the simple code for an ArcTan2, based on what's in the comments at V3 Docs (I can't remember who posted that particular advice, sorry about that).

But, for this to work--since Y actually decrements going up (toward 0 row on the monitor or from the 0, 0, upper left hand corner) instead of incrementing (on a normal cartesian coordinate plane), the Y delta must be reversed.

IE, You've got two points x1, y1, x2, y2.

Angle = Arctan2(y1-y2, x2-x1)

Normally the difference is [second] - [first], but for the Y coordinates you must invert it since screen Y space is sketchy. X space is fine--don't invert it.

Does that make any sense?

Posted on 2004-10-08 03:03:57

locke

Actually, that makes quite a bit of sense, and it solidifies a lot of what I discovered while experimenting with the engine.

I believe that my problem stemmed only from the issue with Y being inverted, as it was effecting many of my calculations. Once I inverted that, things seemed to fall into place.

I still have a drawing problem, but I think that's an issue with how I am calculating the viewport, not related to the engine itself.

Thanks for the solidification, O.

-l

Posted on 2004-10-08 17:00:33

Omni

Whee!

Posted on 2004-10-10 18:50:07


Displaying 1-5 of 5 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.