tesseract 4.1.1
Loading...
Searching...
No Matches
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 51 of file blobs.h.

Constructor & Destructor Documentation

◆ TPOINT() [1/3]

TPOINT::TPOINT ( )
inline

Definition at line 52 of file blobs.h.

52: x(0), y(0) {}
int16_t x
Definition: blobs.h:93
int16_t y
Definition: blobs.h:94

◆ TPOINT() [2/3]

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

Definition at line 53 of file blobs.h.

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

◆ TPOINT() [3/3]

TPOINT::TPOINT ( const ICOORD ic)
inline

Definition at line 54 of file blobs.h.

54: x(ic.x()), y(ic.y()) {}
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52

Member Function Documentation

◆ cross()

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

Definition at line 79 of file blobs.h.

79 {
80 return x * other.y - y * other.x;
81 }

◆ diff()

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

Definition at line 73 of file blobs.h.

73 {
74 x = p1.x - p2.x;
75 y = p1.y - p2.y;
76 }

◆ dot()

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

Definition at line 84 of file blobs.h.

84 {
85 return x * other.x + y * other.y;
86 }

◆ IsCrossed()

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

Definition at line 66 of file blobs.cpp.

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

◆ length()

int TPOINT::length ( ) const
inline

Definition at line 89 of file blobs.h.

89 {
90 return x * x + y * y;
91 }

◆ operator+=()

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

Definition at line 56 of file blobs.h.

56 {
57 x += other.x;
58 y += other.y;
59 }

◆ operator/=()

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

Definition at line 60 of file blobs.h.

60 {
61 x /= divisor;
62 y /= divisor;
63 }

◆ operator==()

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

Definition at line 64 of file blobs.h.

64 {
65 return x == other.x && y == other.y;
66 }

Member Data Documentation

◆ x

int16_t TPOINT::x

Definition at line 93 of file blobs.h.

◆ y

int16_t TPOINT::y

Definition at line 94 of file blobs.h.


The documentation for this struct was generated from the following files: