tesseract v5.3.3.20231005
fpoint.cpp File Reference
#include "fpoint.h"
#include <cmath>
#include <cstdio>

Go to the source code of this file.

Macros

#define _USE_MATH_DEFINES
 

Functions

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

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Definition at line 20 of file fpoint.cpp.

Function Documentation

◆ DistanceBetween()

float DistanceBetween ( FPOINT  A,
FPOINT  B 
)

Definition at line 29 of file fpoint.cpp.

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

◆ NormalizedAngleFrom()

float NormalizedAngleFrom ( FPOINT Point1,
FPOINT Point2,
float  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
angle

Definition at line 44 of file fpoint.cpp.

44 {
45 float NumRadsInCircle = 2.0 * M_PI;
46
47 float Angle = AngleFrom(*Point1, *Point2);
48 if (Angle < 0.0) {
49 Angle += NumRadsInCircle;
50 }
51 Angle *= FullScale / NumRadsInCircle;
52 if (Angle < 0.0 || Angle >= FullScale) {
53 Angle = 0.0;
54 }
55 return (Angle);
56}
#define AngleFrom(A, B)
Definition: fpoint.h:41