Page 1 of 1

Heading/Orientation Help

Posted: June 4th, 2008, 8:29 am
by tault_w118cmh
Anyone been able to decipher the heading values in AoC?

I think I have the offset correct, but it doesn't make sense to me.

It seems they are float values, 0 to 1, but can also be negative. No, it isn't negative for a decrease in x/y values or anything like that, or even angles it seems. It seems they randomly go to negative numbers.

Any help on the heading values would be appreciated.

Posted: June 17th, 2008, 10:42 am
by jinzoh
haha the heading values are very easy mate =)
Go venture into your math book and look up trig functions =p

Posted: June 17th, 2008, 10:54 am
by tault_w118cmh
jinzoh wrote:haha the heading values are very easy mate =)
Go venture into your math book and look up trig functions =p
Hehe, I spent 3 years in college as a trig tutor, so I have a pretty good grasp of them.

The problem I was having is that I was trying to put a meaning behind the heading values. There is no rational reason I can come up with as to why the value of a heading at 90 degrees would be .7, while at 180 it would be 1.

You would think they would be a ratio, but they wern't.

In any case, I have it working now, so no worries.

Still doesn't make sense to me, but eh, guess that's just how it goes.

Posted: June 17th, 2008, 2:51 pm
by jinzoh
Actually there is a very rational reason! Those values are triangle side ratios of the little player arrow on the map (hmmm how do we smat people go from side ratios to angles?). I don't know if you noticed this, but you can actually modify your size and make the character a balloon or a broomstick with some minor tweaking. The game literally treats the player as a bisected triangle.

-PS, you need 4 addresses to do this properly and there actually is a pattern to the madness

Posted: June 17th, 2008, 7:21 pm
by tault_w118cmh
Ah, then there is my problem.

I was only using one offset, x98, for heading. It was the value giving the funky decimal number that didn't make much sense speaking from a trig perspective by itself.

What I ended up doing is getting that value, finding the "quadrent" of my next heading, converting it to a "heading" value, then adjusting my current heading accordingly.

Works ok, just struggles near 0 degrees and 180 degrees (due to only using the decimal number, so I couldn't tell which way to turn). I'll have to take a looksy to see if I can't find these other offsets. I read from code2007 on his forums what offsets to check, so I'll see if it makes it any easier.

Posted: June 18th, 2008, 5:08 am
by code2007
hint: there's another way to do but the simple way is

use
Abs(x2 - x1)
Abs(y2 - y1)
Sqr(A ^ 2 + B ^ 2)

distance from point a to b

cal = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

deg = cal((A ^ 2 - B ^ 2 - C ^ 2) / (B * C * -2))
degree = deg * (180 / 3.14)

Posted: June 18th, 2008, 5:15 am
by tault_w118cmh
Pretty much how I did it :D

Except, I used ArcSin.

Here's a little secret I learned. The ASin method in .Net returns radians, not degrees by default.

You have no idea how long it took me to figure that out. I kept wondering how the hell I was getting values like 1.4.