Tesseract  3.02
tesseract-ocr/classify/fpoint.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  **     Filename:    fpoint.h
00003  **     Purpose:     Abstract data type for 2D points (floating point coords)
00004  **     Author:      Dan Johnson
00005  **     History:     Thu Apr 12 10:50:01 1990, DSJ, Created.
00006  **
00007  **     (c) Copyright Hewlett-Packard Company, 1988.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  ******************************************************************************/
00018 #ifndef   FPOINT_H
00019 #define   FPOINT_H
00020 
00024 #include "host.h"
00025 #include <stdio.h>
00026 #include <math.h>
00027 
00028 /* define data structure to hold 2D points or vectors using floating point */
00029 typedef struct
00030 {
00031   FLOAT32 x, y;
00032 } FPOINT;
00033 typedef FPOINT FVECTOR;
00034 
00038 /* macros for computing miscellaneous functions of 2 points */
00039 #define XDelta(A,B)   ( (B).x - (A).x )
00040 #define YDelta(A,B)   ( (B).y - (A).y )
00041 #define SlopeFrom(A,B)    ( YDelta(A,B) / XDelta(A,B) )
00042 #define AngleFrom(A,B)          ( atan2((double) YDelta(A,B),           \
00043                                         (double) XDelta(A,B) ) )
00044 
00045 #define XIntersectionOf(A,B,X)  ( SlopeFrom(A,B) * ((X) - A.x) + A.y)
00046 
00047 /*-------------------------------------------------------------------------
00048         Public Function Prototypes
00049 ---------------------------------------------------------------------------*/
00050 
00051 FLOAT32 DistanceBetween(FPOINT A, FPOINT B);
00052 
00053 FLOAT32 NormalizedAngleFrom(FPOINT *Point1, FPOINT *Point2, FLOAT32 FullScale);
00054 #endif