projects
/
ctsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r97: Converted Scanner and Projections to C++
[ctsim.git]
/
include
/
kmath.h
diff --git
a/include/kmath.h
b/include/kmath.h
index 5599327d2c285de22af7b1745f3965edf8b86fbd..bb30f05d683f8caf073e37e742ef6bb5c706ed8f 100644
(file)
--- a/
include/kmath.h
+++ b/
include/kmath.h
@@
-9,7
+9,7
@@
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: kmath.h,v 1.1
2 2000/06/13 16:20:31
kevin Exp $
+** $Id: kmath.h,v 1.1
4 2000/06/17 20:12:14
kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
@@
-30,7
+30,6
@@
#include <stdio.h>
#include <math.h>
#include <stdio.h>
#include <math.h>
-#include <algo.h>
#define PI 3.14159265358979323846
#define HALFPI 1.57079632679489661923 /* PI divided by 2 */
#define PI 3.14159265358979323846
#define HALFPI 1.57079632679489661923 /* PI divided by 2 */
@@
-44,23
+43,30
@@
#define F_EPSILON 1.0E-6
#define D_EPSILON 1.0E-10
#define F_EPSILON 1.0E-6
#define D_EPSILON 1.0E-10
-#define DEG_TO_RAD(x) (x*(PI/180.))
-#define RAD_TO_DEG(x) (x*(180./PI))
-
#define ASSUMEDZERO 1E-10
typedef double GRFMTX_2D[3][3];
typedef double GRFMTX_3D[4][4];
#define ASSUMEDZERO 1E-10
typedef double GRFMTX_2D[3][3];
typedef double GRFMTX_3D[4][4];
+inline double
+convertDegreesToRadians (double x)
+{ return (x * (PI/180.)); }
+
+inline double
+convertRadiansToDegrees (double x)
+{ return (x*(180./PI)); }
template<class T>
inline T nearest (double x)
{ return (x > 0 ? static_cast<T>(x+0.5) : static_cast<T>(x-0.5)); }
template<class T>
template<class T>
inline T nearest (double x)
{ return (x > 0 ? static_cast<T>(x+0.5) : static_cast<T>(x-0.5)); }
template<class T>
-inline T clamp (T value, T
upperBounds, T low
erBounds)
+inline T clamp (T value, T
lowerBounds, T upp
erBounds)
{ return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); }
{ return (value >= upperBounds ? upperBounds : (value <= lowerBounds ? lowerBounds : value )); }
+template<class T>
+inline T lineLength (T x1, T y1, T x2, T y2)
+{ return static_cast<T>( sqrt ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) ); }
/* clip.cpp */
int clip_rect(double *x1, double *y1, double *x2, double *y2, const double rect[4]);
/* clip.cpp */
int clip_rect(double *x1, double *y1, double *x2, double *y2, const double rect[4]);