tesseract  4.00.00dev
fpoint.h File Reference
#include "host.h"
#include <stdio.h>
#include <math.h>

Go to the source code of this file.

Classes

struct  FPOINT
 

Macros

#define XDelta(A, B)   ( (B).x - (A).x )
 
#define YDelta(A, B)   ( (B).y - (A).y )
 
#define SlopeFrom(A, B)   ( YDelta(A,B) / XDelta(A,B) )
 
#define AngleFrom(A, B)
 
#define XIntersectionOf(A, B, X)   ( SlopeFrom(A,B) * ((X) - A.x) + A.y)
 

Typedefs

typedef FPOINT FVECTOR
 

Functions

FLOAT32 DistanceBetween (FPOINT A, FPOINT B)
 
FLOAT32 NormalizedAngleFrom (FPOINT *Point1, FPOINT *Point2, FLOAT32 FullScale)
 

Macro Definition Documentation

◆ AngleFrom

#define AngleFrom (   A,
 
)
Value:
( atan2((double) YDelta(A,B), \
(double) XDelta(A,B) ) )
#define XDelta(A, B)
Definition: fpoint.h:39
#define YDelta(A, B)
Definition: fpoint.h:40

Definition at line 42 of file fpoint.h.

◆ SlopeFrom

#define SlopeFrom (   A,
 
)    ( YDelta(A,B) / XDelta(A,B) )

Definition at line 41 of file fpoint.h.

◆ XDelta

#define XDelta (   A,
 
)    ( (B).x - (A).x )

Macros

Definition at line 39 of file fpoint.h.

◆ XIntersectionOf

#define XIntersectionOf (   A,
  B,
 
)    ( SlopeFrom(A,B) * ((X) - A.x) + A.y)

Definition at line 45 of file fpoint.h.

◆ YDelta

#define YDelta (   A,
 
)    ( (B).y - (A).y )

Definition at line 40 of file fpoint.h.

Typedef Documentation

◆ FVECTOR

typedef FPOINT FVECTOR

Definition at line 33 of file fpoint.h.

Function Documentation

◆ DistanceBetween()

FLOAT32 DistanceBetween ( FPOINT  A,
FPOINT  B 
)

Definition at line 30 of file fpoint.cpp.

30  {
31  double xd = XDelta(A, B);
32  double yd = YDelta(A, B);
33  return sqrt(static_cast<double>(xd * xd + yd * yd));
34 }
#define XDelta(A, B)
Definition: fpoint.h:39
#define YDelta(A, B)
Definition: fpoint.h:40

◆ NormalizedAngleFrom()

FLOAT32 NormalizedAngleFrom ( FPOINT Point1,
FPOINT Point2,
FLOAT32  FullScale 
)

Return the angle from Point1 to Point2 normalized to lie in the range 0 to FullScale (where FullScale corresponds to 2*pi or 360 degrees).

Parameters
Point1points to compute angle between
Point2points to compute angle between
FullScalevalue to associate with 2*pi
Returns
none
Note
Globals: none
Exceptions: none
History: Wed Mar 28 14:27:25 1990, DSJ, Created.

Definition at line 48 of file fpoint.cpp.

50  {
51  FLOAT32 Angle;
52  FLOAT32 NumRadsInCircle = 2.0 * PI;
53 
54  Angle = AngleFrom (*Point1, *Point2);
55  if (Angle < 0.0)
56  Angle += NumRadsInCircle;
57  Angle *= FullScale / NumRadsInCircle;
58  if (Angle < 0.0 || Angle >= FullScale)
59  Angle = 0.0;
60  return (Angle);
61 }
#define PI
Definition: const.h:19
#define AngleFrom(A, B)
Definition: fpoint.h:42
float FLOAT32
Definition: host.h:42