Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: Sorrontis on June 06, 2016, 12:11:25 AM

Title: Turret Turning for shortest arc
Post by: Sorrontis on June 06, 2016, 12:11:25 AM
Hi, I'm having trouble making a turret aim turn the shortest direction.

I can make it aim at the right angle, but sometimes, it takes the longest angular route. I work in radians (from 0 to 6.27 rads [6.28 goes back to 0]) , and I have 2 points I give my turret; the original angle and the target angle.

The turret starts by aiming due Right (0 Rad), but keeps its position from the previous firing step.


Essentially, I want it do the what the Bertha does.
Title: Re: Turret Turning for shortest arc
Post by: planetfall on June 06, 2016, 01:06:13 AM
http://knucklecracker.com/wiki/doku.php?id=crpl:docs:shortestangle
Title: Re: Turret Turning for shortest arc
Post by: Sorrontis on June 06, 2016, 01:41:14 AM
Well that works... And it's a little humiliating. I've been working on this for over 2 hours. Although, I think I figured the long way to do it too :)
Title: Re: Turret Turning for shortest arc
Post by: Grayzzur on June 06, 2016, 07:59:42 AM
On the bright side... it's a problem that presents itself often enough to warrant the solution be handed to you in this way. :)
Title: Re: Turret Turning for shortest arc
Post by: Sorrontis on June 06, 2016, 10:43:56 AM
It must be :)