Forum

returning angles in different ways

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

returning angles in different ways

Postby behind_you » Tue May 31, 2011 9:22 am

ok I am making a code that requires self.angles_y.

self.angles_y is ranged between -180 and 180

how can i make it so that it has no range (ie it increases when you turn right, decrease when you turn left). using the -180 180 range or the 0 360 range causes problems. when your angle is 180 and it increases, it instantly becomes -180.

any help is appreciated
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Spike » Tue May 31, 2011 12:05 pm

you may need to consider quadrants and to possibly add 360 to one angle if you're comparing them.

otherwise, avoid the use of writeangle even in engine code. good luck with that...
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby behind_you » Tue Jun 14, 2011 7:55 am

hmm. what are quadrants?

i could add 360 every time it hits 359. not the best way..
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Spirit » Tue Jun 14, 2011 1:03 pm

Not sure if this is what spike means but quadrants are what you get when you divide the circle into 4 parts, eg 0-90, 90-180 and so on. What quadrant is called what might differ on context so I won't mention that.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Postby behind_you » Wed Jun 15, 2011 9:20 am

Spirit wrote:Not sure if this is what spike means but quadrants are what you get when you divide the circle into 4 parts, eg 0-90, 90-180 and so on. What quadrant is called what might differ on context so I won't mention that.


i remember this in math class. thanks spirit.

So i guess there's no type of .movement vector but for turning? bummer...
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Spike » Wed Jun 15, 2011 12:04 pm

diff = new - old;
if (diff > 180)
diff -= 360;
if (diff < -180)
diff += 360;

of course, if they do manage to do a 180 degree turn in the span of a single frame, your mod will think they're turning the other way around. If your framerate is 72fps+, that's not really a likely situation (unless they're using various rj/turn scripts).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest