Tesseract
3.02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
fpoint.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
** Filename: fpoint.c
3
** Purpose: Abstract data type for a 2D point (floating point coords)
4
** Author: Dan Johnson
5
** History: Thu Apr 12 10:44:15 1990, DSJ, Created.
6
**
7
** (c) Copyright Hewlett-Packard Company, 1988.
8
** Licensed under the Apache License, Version 2.0 (the "License");
9
** you may not use this file except in compliance with the License.
10
** You may obtain a copy of the License at
11
** http://www.apache.org/licenses/LICENSE-2.0
12
** Unless required by applicable law or agreed to in writing, software
13
** distributed under the License is distributed on an "AS IS" BASIS,
14
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
** See the License for the specific language governing permissions and
16
** limitations under the License.
17
******************************************************************************/
21
#include "
const.h
"
22
#include "
fpoint.h
"
23
#include <stdio.h>
24
#include <math.h>
25
29
/*---------------------------------------------------------------------------*/
30
31
FLOAT32
DistanceBetween
(
FPOINT
A,
FPOINT
B) {
32
double
xd =
XDelta
(A, B);
33
double
yd =
YDelta
(A, B);
34
return
sqrt(static_cast<double>(xd * xd + yd * yd));
35
}
36
37
38
39
FLOAT32
NormalizedAngleFrom
(
FPOINT
*Point1,
40
FPOINT
*Point2,
41
FLOAT32
FullScale) {
42
/*
43
** Parameters:
44
** Point1, Point2 points to compute angle between
45
** FullScale value to associate with 2*pi
46
** Globals: none
47
** Operation: Return the angle from Point1 to Point2 normalized to
48
** lie in the range 0 to FullScale (where FullScale corresponds
49
** to 2*pi or 360 degrees).
50
** Return: none
51
** Exceptions: none
52
** History: Wed Mar 28 14:27:25 1990, DSJ, Created.
53
*/
54
FLOAT32
Angle;
55
FLOAT32
NumRadsInCircle = 2.0 *
PI
;
56
57
Angle =
AngleFrom
(*Point1, *Point2);
58
if
(Angle < 0.0)
59
Angle += NumRadsInCircle;
60
Angle *= FullScale / NumRadsInCircle;
61
if
(Angle < 0.0 || Angle >= FullScale)
62
Angle = 0.0;
63
return
(Angle);
64
65
}
/* NormalizedAngleFrom */
mnt
data
src
tesseract-ocr
classify
fpoint.cpp
Generated on Thu Nov 1 2012 20:19:46 for Tesseract by
1.8.1