summaryrefslogtreecommitdiff
path: root/src/tables.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tables.c')
-rw-r--r--src/tables.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/tables.c b/src/tables.c
index 9c014513..543fda8c 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -38,33 +38,37 @@
//
//-----------------------------------------------------------------------------
-
-
-
-
#include "tables.h"
+// to get a global angle from cartesian coordinates, the coordinates are
+// flipped until they are in the first octant of the coordinate system, then
+// the y (<=x) is scaled and divided by x to get a tangent (slope) value
+// which is looked up in the tantoangle[] table. The +1 size is to handle
+// the case when x==y without additional checking.
-
-
-int
-SlopeDiv
-( unsigned num,
- unsigned den)
+int SlopeDiv(unsigned int num, unsigned int den)
{
- unsigned ans;
+ unsigned ans;
if (den < 512)
- return SLOPERANGE;
-
- ans = (num<<3)/(den>>8);
+ {
+ return SLOPERANGE;
+ }
+ else
+ {
+ ans = (num << 3) / (den >> 8);
- return ans <= SLOPERANGE ? ans : SLOPERANGE;
+ if (ans <= SLOPERANGE)
+ {
+ return ans;
+ }
+ else
+ {
+ return SLOPERANGE;
+ }
+ }
}
-
-
-
const int finetangent[4096] =
{
-170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683,