mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Move content of ipoints.h to points.h and remove ipoints.h
Both include files depended on each other, so it did not make sense to separate them. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
57a6f1d22e
commit
8c56b8f58c
@ -16,7 +16,6 @@ noinst_HEADERS = \
|
||||
ccstruct.h coutln.h crakedge.h \
|
||||
debugpixa.h detlinefit.h dppoint.h fontinfo.h \
|
||||
imagedata.h \
|
||||
ipoints.h \
|
||||
linlsq.h matrix.h mod128.h normalis.h \
|
||||
ocrblock.h ocrpara.h ocrrow.h otsuthr.h \
|
||||
pageres.h params_training_featdef.h \
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "environ.h" // for l_uint32
|
||||
#include "helpers.h" // for UpdateRange, IntCastRounded
|
||||
#include "host.h" // for NearlyEqual, TRUE
|
||||
#include "ipoints.h" // for operator+=, ICOORD::rotate
|
||||
#include "points.h" // for operator+=, ICOORD::rotate
|
||||
|
||||
struct Pix;
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <cstdint> // for int16_t, int32_t
|
||||
#include "bits16.h" // for BITS16
|
||||
#include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK
|
||||
#include "ipoints.h" // for operator+=
|
||||
#include "mod128.h" // for DIR128, DIRBITS
|
||||
#include "platform.h" // for DLLSYM
|
||||
#include "points.h" // for ICOORD, FCOORD
|
||||
|
@ -1,485 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: ipoints.h (Formerly icoords.h)
|
||||
* Description: Inline functions for coords.h.
|
||||
* Author: Ray Smith
|
||||
* Created: Fri Jun 21 15:14:21 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef IPOINTS_H
|
||||
#define IPOINTS_H
|
||||
|
||||
#include <cmath>
|
||||
#include "points.h" // ICOORD
|
||||
|
||||
/**********************************************************************
|
||||
* operator!
|
||||
*
|
||||
* Rotate an ICOORD 90 degrees anticlockwise.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator! ( //rotate 90 deg anti
|
||||
const ICOORD & src //thing to rotate
|
||||
) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = -src.ycoord;
|
||||
result.ycoord = src.xcoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Unary minus of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator- ( //unary minus
|
||||
const ICOORD & src //thing to minus
|
||||
) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = -src.xcoord;
|
||||
result.ycoord = -src.ycoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+
|
||||
*
|
||||
* Add 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator+ ( //sum vectors
|
||||
const ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
ICOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord + op2.xcoord;
|
||||
sum.ycoord = op1.ycoord + op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+=
|
||||
*
|
||||
* Add 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator+= ( //sum vectors
|
||||
ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
op1.xcoord += op2.xcoord;
|
||||
op1.ycoord += op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Subtract 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator- ( //subtract vectors
|
||||
const ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
ICOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord - op2.xcoord;
|
||||
sum.ycoord = op1.ycoord - op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-=
|
||||
*
|
||||
* Subtract 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator-= ( //sum vectors
|
||||
ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
op1.xcoord -= op2.xcoord;
|
||||
op1.ycoord -= op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator%
|
||||
*
|
||||
* Scalar product of 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline int32_t
|
||||
operator% ( //scalar product
|
||||
const ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Cross product of 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline int32_t operator *( //cross product
|
||||
const ICOORD &op1, //operands
|
||||
const ICOORD &op2) {
|
||||
return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Scalar multiply of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD operator *( //scalar multiply
|
||||
const ICOORD &op1, //operands
|
||||
int16_t scale) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline ICOORD operator *( //scalar multiply
|
||||
int16_t scale,
|
||||
const ICOORD &op1 //operands
|
||||
) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*=
|
||||
*
|
||||
* Scalar multiply of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator*= ( //scalar multiply
|
||||
ICOORD & op1, //operands
|
||||
int16_t scale) {
|
||||
op1.xcoord *= scale;
|
||||
op1.ycoord *= scale;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/
|
||||
*
|
||||
* Scalar divide of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator/ ( //scalar divide
|
||||
const ICOORD & op1, //operands
|
||||
int16_t scale) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord / scale;
|
||||
result.ycoord = op1.ycoord / scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/=
|
||||
*
|
||||
* Scalar divide of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator/= ( //scalar divide
|
||||
ICOORD & op1, //operands
|
||||
int16_t scale) {
|
||||
op1.xcoord /= scale;
|
||||
op1.ycoord /= scale;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* ICOORD::rotate
|
||||
*
|
||||
* Rotate an ICOORD by the given (normalized) (cos,sin) vector.
|
||||
**********************************************************************/
|
||||
|
||||
inline void ICOORD::rotate( //rotate by vector
|
||||
const FCOORD& vec) {
|
||||
int16_t tmp;
|
||||
|
||||
tmp = (int16_t) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5);
|
||||
ycoord = (int16_t) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5);
|
||||
xcoord = tmp;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator!
|
||||
*
|
||||
* Rotate an FCOORD 90 degrees anticlockwise.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator! ( //rotate 90 deg anti
|
||||
const FCOORD & src //thing to rotate
|
||||
) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = -src.ycoord;
|
||||
result.ycoord = src.xcoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Unary minus of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator- ( //unary minus
|
||||
const FCOORD & src //thing to minus
|
||||
) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = -src.xcoord;
|
||||
result.ycoord = -src.ycoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+
|
||||
*
|
||||
* Add 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator+ ( //sum vectors
|
||||
const FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
FCOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord + op2.xcoord;
|
||||
sum.ycoord = op1.ycoord + op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+=
|
||||
*
|
||||
* Add 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator+= ( //sum vectors
|
||||
FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
op1.xcoord += op2.xcoord;
|
||||
op1.ycoord += op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Subtract 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator- ( //subtract vectors
|
||||
const FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
FCOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord - op2.xcoord;
|
||||
sum.ycoord = op1.ycoord - op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-=
|
||||
*
|
||||
* Subtract 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator-= ( //sum vectors
|
||||
FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
op1.xcoord -= op2.xcoord;
|
||||
op1.ycoord -= op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator%
|
||||
*
|
||||
* Scalar product of 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline float
|
||||
operator% ( //scalar product
|
||||
const FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Cross product of 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline float operator *( //cross product
|
||||
const FCOORD &op1, //operands
|
||||
const FCOORD &op2) {
|
||||
return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Scalar multiply of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD operator *( //scalar multiply
|
||||
const FCOORD &op1, //operands
|
||||
float scale) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline FCOORD operator *( //scalar multiply
|
||||
float scale,
|
||||
const FCOORD &op1 //operands
|
||||
) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*=
|
||||
*
|
||||
* Scalar multiply of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator*= ( //scalar multiply
|
||||
FCOORD & op1, //operands
|
||||
float scale) {
|
||||
op1.xcoord *= scale;
|
||||
op1.ycoord *= scale;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/
|
||||
*
|
||||
* Scalar divide of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator/ ( //scalar divide
|
||||
const FCOORD & op1, //operands
|
||||
float scale) {
|
||||
FCOORD result; //output
|
||||
|
||||
if (scale != 0) {
|
||||
result.xcoord = op1.xcoord / scale;
|
||||
result.ycoord = op1.ycoord / scale;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/=
|
||||
*
|
||||
* Scalar divide of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator/= ( //scalar divide
|
||||
FCOORD & op1, //operands
|
||||
float scale) {
|
||||
if (scale != 0) {
|
||||
op1.xcoord /= scale;
|
||||
op1.ycoord /= scale;
|
||||
}
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* rotate
|
||||
*
|
||||
* Rotate an FCOORD by the given (normalized) (cos,sin) vector.
|
||||
**********************************************************************/
|
||||
|
||||
inline void FCOORD::rotate( //rotate by vector
|
||||
const FCOORD vec) {
|
||||
float tmp;
|
||||
|
||||
tmp = xcoord * vec.x () - ycoord * vec.y ();
|
||||
ycoord = ycoord * vec.x () + xcoord * vec.y ();
|
||||
xcoord = tmp;
|
||||
}
|
||||
|
||||
inline void FCOORD::unrotate(const FCOORD& vec) {
|
||||
rotate(FCOORD(vec.x(), -vec.y()));
|
||||
}
|
||||
|
||||
#endif
|
@ -317,5 +317,463 @@ class DLLSYM FCOORD
|
||||
float ycoord;
|
||||
};
|
||||
|
||||
#include "ipoints.h" /*do inline funcs */
|
||||
/**********************************************************************
|
||||
* operator!
|
||||
*
|
||||
* Rotate an ICOORD 90 degrees anticlockwise.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator! ( //rotate 90 deg anti
|
||||
const ICOORD & src //thing to rotate
|
||||
) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = -src.ycoord;
|
||||
result.ycoord = src.xcoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Unary minus of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator- ( //unary minus
|
||||
const ICOORD & src //thing to minus
|
||||
) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = -src.xcoord;
|
||||
result.ycoord = -src.ycoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+
|
||||
*
|
||||
* Add 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator+ ( //sum vectors
|
||||
const ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
ICOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord + op2.xcoord;
|
||||
sum.ycoord = op1.ycoord + op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+=
|
||||
*
|
||||
* Add 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator+= ( //sum vectors
|
||||
ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
op1.xcoord += op2.xcoord;
|
||||
op1.ycoord += op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Subtract 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator- ( //subtract vectors
|
||||
const ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
ICOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord - op2.xcoord;
|
||||
sum.ycoord = op1.ycoord - op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-=
|
||||
*
|
||||
* Subtract 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator-= ( //sum vectors
|
||||
ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
op1.xcoord -= op2.xcoord;
|
||||
op1.ycoord -= op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator%
|
||||
*
|
||||
* Scalar product of 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline int32_t
|
||||
operator% ( //scalar product
|
||||
const ICOORD & op1, //operands
|
||||
const ICOORD & op2) {
|
||||
return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Cross product of 2 ICOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline int32_t operator *( //cross product
|
||||
const ICOORD &op1, //operands
|
||||
const ICOORD &op2) {
|
||||
return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Scalar multiply of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD operator *( //scalar multiply
|
||||
const ICOORD &op1, //operands
|
||||
int16_t scale) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline ICOORD operator *( //scalar multiply
|
||||
int16_t scale,
|
||||
const ICOORD &op1 //operands
|
||||
) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*=
|
||||
*
|
||||
* Scalar multiply of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator*= ( //scalar multiply
|
||||
ICOORD & op1, //operands
|
||||
int16_t scale) {
|
||||
op1.xcoord *= scale;
|
||||
op1.ycoord *= scale;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/
|
||||
*
|
||||
* Scalar divide of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD
|
||||
operator/ ( //scalar divide
|
||||
const ICOORD & op1, //operands
|
||||
int16_t scale) {
|
||||
ICOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord / scale;
|
||||
result.ycoord = op1.ycoord / scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/=
|
||||
*
|
||||
* Scalar divide of an ICOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline ICOORD &
|
||||
operator/= ( //scalar divide
|
||||
ICOORD & op1, //operands
|
||||
int16_t scale) {
|
||||
op1.xcoord /= scale;
|
||||
op1.ycoord /= scale;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* ICOORD::rotate
|
||||
*
|
||||
* Rotate an ICOORD by the given (normalized) (cos,sin) vector.
|
||||
**********************************************************************/
|
||||
|
||||
inline void ICOORD::rotate( //rotate by vector
|
||||
const FCOORD& vec) {
|
||||
int16_t tmp;
|
||||
|
||||
tmp = (int16_t) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5);
|
||||
ycoord = (int16_t) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5);
|
||||
xcoord = tmp;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator!
|
||||
*
|
||||
* Rotate an FCOORD 90 degrees anticlockwise.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator! ( //rotate 90 deg anti
|
||||
const FCOORD & src //thing to rotate
|
||||
) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = -src.ycoord;
|
||||
result.ycoord = src.xcoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Unary minus of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator- ( //unary minus
|
||||
const FCOORD & src //thing to minus
|
||||
) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = -src.xcoord;
|
||||
result.ycoord = -src.ycoord;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+
|
||||
*
|
||||
* Add 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator+ ( //sum vectors
|
||||
const FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
FCOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord + op2.xcoord;
|
||||
sum.ycoord = op1.ycoord + op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator+=
|
||||
*
|
||||
* Add 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator+= ( //sum vectors
|
||||
FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
op1.xcoord += op2.xcoord;
|
||||
op1.ycoord += op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-
|
||||
*
|
||||
* Subtract 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator- ( //subtract vectors
|
||||
const FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
FCOORD sum; //result
|
||||
|
||||
sum.xcoord = op1.xcoord - op2.xcoord;
|
||||
sum.ycoord = op1.ycoord - op2.ycoord;
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator-=
|
||||
*
|
||||
* Subtract 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator-= ( //sum vectors
|
||||
FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
op1.xcoord -= op2.xcoord;
|
||||
op1.ycoord -= op2.ycoord;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator%
|
||||
*
|
||||
* Scalar product of 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline float
|
||||
operator% ( //scalar product
|
||||
const FCOORD & op1, //operands
|
||||
const FCOORD & op2) {
|
||||
return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Cross product of 2 FCOORDS.
|
||||
**********************************************************************/
|
||||
|
||||
inline float operator *( //cross product
|
||||
const FCOORD &op1, //operands
|
||||
const FCOORD &op2) {
|
||||
return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*
|
||||
*
|
||||
* Scalar multiply of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD operator *( //scalar multiply
|
||||
const FCOORD &op1, //operands
|
||||
float scale) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline FCOORD operator *( //scalar multiply
|
||||
float scale,
|
||||
const FCOORD &op1 //operands
|
||||
) {
|
||||
FCOORD result; //output
|
||||
|
||||
result.xcoord = op1.xcoord * scale;
|
||||
result.ycoord = op1.ycoord * scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator*=
|
||||
*
|
||||
* Scalar multiply of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator*= ( //scalar multiply
|
||||
FCOORD & op1, //operands
|
||||
float scale) {
|
||||
op1.xcoord *= scale;
|
||||
op1.ycoord *= scale;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/
|
||||
*
|
||||
* Scalar divide of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD
|
||||
operator/ ( //scalar divide
|
||||
const FCOORD & op1, //operands
|
||||
float scale) {
|
||||
FCOORD result; //output
|
||||
|
||||
if (scale != 0) {
|
||||
result.xcoord = op1.xcoord / scale;
|
||||
result.ycoord = op1.ycoord / scale;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* operator/=
|
||||
*
|
||||
* Scalar divide of an FCOORD.
|
||||
**********************************************************************/
|
||||
|
||||
inline FCOORD &
|
||||
operator/= ( //scalar divide
|
||||
FCOORD & op1, //operands
|
||||
float scale) {
|
||||
if (scale != 0) {
|
||||
op1.xcoord /= scale;
|
||||
op1.ycoord /= scale;
|
||||
}
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* rotate
|
||||
*
|
||||
* Rotate an FCOORD by the given (normalized) (cos,sin) vector.
|
||||
**********************************************************************/
|
||||
|
||||
inline void FCOORD::rotate( //rotate by vector
|
||||
const FCOORD vec) {
|
||||
float tmp;
|
||||
|
||||
tmp = xcoord * vec.x () - ycoord * vec.y ();
|
||||
ycoord = ycoord * vec.x () + xcoord * vec.y ();
|
||||
xcoord = tmp;
|
||||
}
|
||||
|
||||
inline void FCOORD::unrotate(const FCOORD& vec) {
|
||||
rotate(FCOORD(vec.x(), -vec.y()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "coutln.h" // for C_OUTLINE
|
||||
#include "errcode.h" // for ASSERT_HOST
|
||||
#include "host.h" // for FALSE, TRUE
|
||||
#include "ipoints.h" // for operator+=, operator*=
|
||||
#include "mod128.h" // for DIR128
|
||||
#include "params.h" // for BoolParam, BOOL_VAR
|
||||
#include "points.h" // for ICOORD
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <cmath> // for ceil, floor
|
||||
#include <cstdint> // for INT16_MAX
|
||||
#include <cstdio> // for FILE
|
||||
#include "ipoints.h" // for operator+=, operator-=, ICOORD::rotate
|
||||
#include "platform.h" // for DLLSYM
|
||||
#include "points.h" // for ICOORD, FCOORD
|
||||
#include "scrollview.h" // for ScrollView, ScrollView::Color
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "allheaders.h" // for pixCreate, pixGetDepth
|
||||
#include "genericvector.h" // for GenericVector
|
||||
#include "host.h" // for TRUE, FALSE
|
||||
#include "ipoints.h" // for operator+=
|
||||
#include "points.h" // for operator+=, FCOORD, ICOORD
|
||||
|
||||
class DENORM;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user