Tesseract  3.02
tesseract-ocr/ccstruct/quadratc.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        quadratc.h  (Formerly quadrtic.h)
00003  * Description: Code for the QUAD_COEFFS class.
00004  * Author:              Ray Smith
00005  * Created:             Tue Oct 08 17:24:40 BST 1991
00006  *
00007  * (C) Copyright 1991, Hewlett-Packard Ltd.
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 
00020 #ifndef           QUADRATC_H
00021 #define           QUADRATC_H
00022 
00023 #include          "points.h"
00024 
00025 class QUAD_COEFFS
00026 {
00027   public:
00028     QUAD_COEFFS() {
00029     }                            //empty constructor
00030     QUAD_COEFFS(             //constructor
00031                 double xsq,  //coefficients
00032                 float x,
00033                 float constant) {
00034       a = xsq;
00035       b = x;
00036       c = constant;
00037     }
00038 
00039     float y(                  //evaluate
00040             float x) const {  //at x
00041       return (float) ((a * x + b) * x + c);
00042     }
00043 
00044     void move(               // reposition word
00045               ICOORD vec) {  // by vector
00046       /************************************************************
00047         y - q = a (x - p)^2 + b (x - p) + c
00048         y - q = ax^2 - 2apx + ap^2 + bx - bp + c
00049           y = ax^2 + (b - 2ap)x + (c - bp + ap^2 + q)
00050       ************************************************************/
00051       inT16 p = vec.x ();
00052       inT16 q = vec.y ();
00053 
00054       c = (float) (c - b * p + a * p * p + q);
00055       b = (float) (b - 2 * a * p);
00056     }
00057 
00058     double a;                    //x squared
00059     float b;                     //x
00060     float c;                     //constant
00061   private:
00062 };
00063 #endif