tesseract  5.0.0-alpha-619-ge9db
DIR128 Class Reference

#include <mod128.h>

Public Member Functions

 DIR128 ()=default
 
 DIR128 (int16_t value)
 
 DIR128 (const FCOORD fc)
 
DIR128operator= (int16_t value)
 
int8_t operator- (const DIR128 &minus) const
 
DIR128 operator+ (const DIR128 &add) const
 
DIR128operator+= (const DIR128 &add)
 
int8_t get_dir () const
 

Detailed Description

Definition at line 28 of file mod128.h.

Constructor & Destructor Documentation

◆ DIR128() [1/3]

DIR128::DIR128 ( )
default

◆ DIR128() [2/3]

DIR128::DIR128 ( int16_t  value)
inline

Definition at line 33 of file mod128.h.

35  { //value to assign
36  value %= MODULUS; //modulo arithmetic
37  if (value < 0)
38  value += MODULUS; //done properly
39  dir = static_cast<int8_t>(value);

◆ DIR128() [3/3]

DIR128::DIR128 ( const FCOORD  fc)

Definition at line 62 of file mod128.cpp.

66  {
67  int high, low, current; //binary search
68 
69  low = 0;
70  if (fc.y () == 0) {
71  if (fc.x () >= 0)
72  dir = 0;
73  else
74  dir = MODULUS / 2;
75  return;
76  }
77  high = MODULUS;
78  do {
79  current = (high + low) / 2;
80  if (dirtab[current] * fc >= 0)
81  low = current;
82  else
83  high = current;
84  }
85  while (high - low > 1);

Member Function Documentation

◆ get_dir()

int8_t DIR128::get_dir ( ) const
inline

Definition at line 75 of file mod128.h.

76  { //access function
77  return dir;

◆ operator+()

DIR128 DIR128::operator+ ( const DIR128 add) const
inline

Definition at line 62 of file mod128.h.

65  {
66  DIR128 result; //sum
67 
68  result = dir + add.dir; //let = do the work
69  return result;

◆ operator+=()

DIR128& DIR128::operator+= ( const DIR128 add)
inline

Definition at line 70 of file mod128.h.

72  {
73  *this = dir + add.dir; //let = do the work
74  return *this;

◆ operator-()

int8_t DIR128::operator- ( const DIR128 minus) const
inline

Definition at line 50 of file mod128.h.

53  {
54  //result
55  int16_t result = dir - minus.dir;
56 
57  if (result > MODULUS / 2)
58  result -= MODULUS; //get in range
59  else if (result < -MODULUS / 2)
60  result += MODULUS;
61  return static_cast<int8_t>(result);

◆ operator=()

DIR128& DIR128::operator= ( int16_t  value)
inline

Definition at line 42 of file mod128.h.

44  { //value to assign
45  value %= MODULUS; //modulo arithmetic
46  if (value < 0)
47  value += MODULUS; //done properly
48  dir = static_cast<int8_t>(value);
49  return *this;

The documentation for this class was generated from the following files:
DIR128
Definition: mod128.h:28
FCOORD::y
float y() const
Definition: points.h:209
MODULUS
#define MODULUS
Definition: mod128.h:24
FCOORD::x
float x() const
Definition: points.h:206