tesseract v5.3.3.20231005
tesseract::TPOINT Struct Reference

#include <blobs.h>

Public Member Functions

 TPOINT ()=default
 
 TPOINT (TDimension vx, TDimension 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

TDimension x = 0
 
TDimension y = 0
 

Detailed Description

Definition at line 48 of file blobs.h.

Constructor & Destructor Documentation

◆ TPOINT() [1/3]

tesseract::TPOINT::TPOINT ( )
default

◆ TPOINT() [2/3]

tesseract::TPOINT::TPOINT ( TDimension  vx,
TDimension  vy 
)
inline

Definition at line 50 of file blobs.h.

50: x(vx), y(vy) {}
TDimension x
Definition: blobs.h:89
TDimension y
Definition: blobs.h:90

◆ TPOINT() [3/3]

tesseract::TPOINT::TPOINT ( const ICOORD ic)
inline

Definition at line 51 of file blobs.h.

51: x(ic.x()), y(ic.y()) {}

Member Function Documentation

◆ cross()

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

Definition at line 75 of file blobs.h.

75 {
76 return x * other.y - y * other.x;
77 }

◆ diff()

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

Definition at line 69 of file blobs.h.

69 {
70 x = p1.x - p2.x;
71 y = p1.y - p2.y;
72 }

◆ dot()

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

Definition at line 80 of file blobs.h.

80 {
81 return x * other.x + y * other.y;
82 }

◆ IsCrossed()

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

Definition at line 65 of file blobs.cpp.

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

◆ length()

int tesseract::TPOINT::length ( ) const
inline

Definition at line 85 of file blobs.h.

85 {
86 return x * x + y * y;
87 }

◆ operator+=()

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

Definition at line 53 of file blobs.h.

53 {
54 x += other.x;
55 y += other.y;
56 }

◆ operator/=()

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

Definition at line 57 of file blobs.h.

57 {
58 x /= divisor;
59 y /= divisor;
60 }

◆ operator==()

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

Definition at line 61 of file blobs.h.

61 {
62 return x == other.x && y == other.y;
63 }

Member Data Documentation

◆ x

TDimension tesseract::TPOINT::x = 0

Definition at line 89 of file blobs.h.

◆ y

TDimension tesseract::TPOINT::y = 0

Definition at line 90 of file blobs.h.


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