tesseract  5.0.0-alpha-619-ge9db
TPOINT Struct Reference

#include <blobs.h>

Public Member Functions

 TPOINT ()
 
 TPOINT (int16_t vx, int16_t vy)
 
 TPOINT (const ICOORD &ic)
 
void operator+= (const TPOINT &other)
 
void operator/= (int divisor)
 
bool operator== (const TPOINT &other) const
 
void diff (const TPOINT &p1, const TPOINT &p2)
 
int cross (const TPOINT &other) const
 
int dot (const TPOINT &other) const
 
int length () const
 

Static Public Member Functions

static bool IsCrossed (const TPOINT &a0, const TPOINT &a1, const TPOINT &b0, const TPOINT &b1)
 

Public Attributes

int16_t x
 
int16_t y
 

Detailed Description

Definition at line 49 of file blobs.h.

Constructor & Destructor Documentation

◆ TPOINT() [1/3]

TPOINT::TPOINT ( )
inline

Definition at line 50 of file blobs.h.

50 {

◆ TPOINT() [2/3]

TPOINT::TPOINT ( int16_t  vx,
int16_t  vy 
)
inline

Definition at line 51 of file blobs.h.

51 : x(0), y(0) {}

◆ TPOINT() [3/3]

TPOINT::TPOINT ( const ICOORD ic)
inline

Definition at line 52 of file blobs.h.

52 : x(vx), y(vy) {}

Member Function Documentation

◆ cross()

int TPOINT::cross ( const TPOINT other) const
inline

Definition at line 77 of file blobs.h.

78  {
79  return x * other.y - y * other.x;

◆ diff()

void TPOINT::diff ( const TPOINT p1,
const TPOINT p2 
)
inline

Definition at line 71 of file blobs.h.

72  {
73  x = p1.x - p2.x;
74  y = p1.y - p2.y;

◆ dot()

int TPOINT::dot ( const TPOINT other) const
inline

Definition at line 82 of file blobs.h.

83  {
84  return x * other.x + y * other.y;

◆ IsCrossed()

bool TPOINT::IsCrossed ( const TPOINT a0,
const TPOINT a1,
const TPOINT b0,
const TPOINT b1 
)
static

Definition at line 65 of file blobs.cpp.

66  {
67  TPOINT b0a1, b0a0, a1b1, b0b1, a1a0;
68 
69  b0a1.x = a1.x - b0.x;
70  b0a0.x = a0.x - b0.x;
71  a1b1.x = b1.x - a1.x;
72  b0b1.x = b1.x - b0.x;
73  a1a0.x = a0.x - a1.x;
74  b0a1.y = a1.y - b0.y;
75  b0a0.y = a0.y - b0.y;
76  a1b1.y = b1.y - a1.y;
77  b0b1.y = b1.y - b0.y;
78  a1a0.y = a0.y - a1.y;
79 
80  int b0a1xb0b1 = b0a1.cross(b0b1);
81  int b0b1xb0a0 = b0b1.cross(b0a0);
82  int a1b1xa1a0 = a1b1.cross(a1a0);
83  // For clarity, we want a1a0.cross(a1b0) here but we have b0a1 instead of a1b0
84  // so use -a1b0.cross(b0a1) instead, which is the same.
85  int a1a0xa1b0 = -a1a0.cross(b0a1);
86 
87  return ((b0a1xb0b1 > 0 && b0b1xb0a0 > 0) ||
88  (b0a1xb0b1 < 0 && b0b1xb0a0 < 0)) &&
89  ((a1b1xa1a0 > 0 && a1a0xa1b0 > 0) || (a1b1xa1a0 < 0 && a1a0xa1b0 < 0));
90 }

◆ length()

int TPOINT::length ( ) const
inline

Definition at line 87 of file blobs.h.

88  {
89  return x * x + y * y;

◆ operator+=()

void TPOINT::operator+= ( const TPOINT other)
inline

Definition at line 54 of file blobs.h.

55  {
56  x += other.x;
57  y += other.y;

◆ operator/=()

void TPOINT::operator/= ( int  divisor)
inline

Definition at line 58 of file blobs.h.

59  {
60  x /= divisor;
61  y /= divisor;

◆ operator==()

bool TPOINT::operator== ( const TPOINT other) const
inline

Definition at line 62 of file blobs.h.

63  {
64  return x == other.x && y == other.y;

Member Data Documentation

◆ x

int16_t TPOINT::x

Definition at line 91 of file blobs.h.

◆ y

int16_t TPOINT::y

Definition at line 92 of file blobs.h.


The documentation for this struct was generated from the following files:
TPOINT
Definition: blobs.h:49
TPOINT::x
int16_t x
Definition: blobs.h:91
TPOINT::y
int16_t y
Definition: blobs.h:92
TPOINT::cross
int cross(const TPOINT &other) const
Definition: blobs.h:77