tesseract 3.04.01

classify/fpoint.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  **     Filename:    fpoint.c
00003  **     Purpose:     Abstract data type for a 2D point (floating point coords)
00004  **     Author:      Dan Johnson
00005  **     History:     Thu Apr 12 10:44:15 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 /*----------------------------------------------------------------------------
00019           Include Files and Type Defines
00020 ----------------------------------------------------------------------------*/
00021 #include "const.h"
00022 #include "fpoint.h"
00023 #include <stdio.h>
00024 #include <math.h>
00025 
00026 /*----------------------------------------------------------------------------
00027               Public Code
00028 ----------------------------------------------------------------------------*/
00029 
00030 FLOAT32 DistanceBetween(FPOINT A, FPOINT B) {
00031   double xd = XDelta(A, B);
00032   double yd = YDelta(A, B);
00033   return sqrt(static_cast<double>(xd * xd + yd * yd));
00034 }
00035 
00048 FLOAT32 NormalizedAngleFrom(FPOINT *Point1,
00049                             FPOINT *Point2,
00050                             FLOAT32 FullScale) {
00051   FLOAT32 Angle;
00052   FLOAT32 NumRadsInCircle = 2.0 * PI;
00053 
00054   Angle = AngleFrom (*Point1, *Point2);
00055   if (Angle < 0.0)
00056     Angle += NumRadsInCircle;
00057   Angle *= FullScale / NumRadsInCircle;
00058   if (Angle < 0.0 || Angle >= FullScale)
00059     Angle = 0.0;
00060   return (Angle);
00061 
00062 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines