projects
/
ctsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use OpenMP for signal filtering
[ctsim.git]
/
libctsupport
/
xform.cpp
diff --git
a/libctsupport/xform.cpp
b/libctsupport/xform.cpp
index abf47500ad675a5b15ac96e8ac253c69d4fb5182..a8f09560d7aaa8871729db151eccbbf64b31e053 100644
(file)
--- a/
libctsupport/xform.cpp
+++ b/
libctsupport/xform.cpp
@@
-1,8
+1,6
@@
/*****************************************************************************
** This is part of the CTSim program
/*****************************************************************************
** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
-**
-** $Id: xform.cpp,v 1.2 2000/06/19 19:04:05 kevin Exp $
+** Copyright (c) 1983-2009 Kevin Rosenberg
**
** 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
@@
-22,16
+20,16
@@
/* NAME
/* NAME
- * rotate2d Rotates an array of 2 dimensional vectors
+ * rotate2d
Rotates an array of 2 dimensional vectors
*
* SYNOPSIS
* rotate2d (x, y, n, angle)
*
* SYNOPSIS
* rotate2d (x, y, n, angle)
- * double x[], y[] Array of points
- * int n Number of points in array
- * double angle Rotation angle (counter-clockwise)
+ * double x[], y[]
Array of points
+ * int n
Number of points in array
+ * double angle
Rotation angle (counter-clockwise)
*/
*/
-void
+void
rotate2d (double x[], double y[], int n, double angle)
{
double cos_theta = cos (angle);
rotate2d (double x[], double y[], int n, double angle)
{
double cos_theta = cos (angle);
@@
-47,16
+45,16
@@
rotate2d (double x[], double y[], int n, double angle)
/* NAME
/* NAME
- * xlat2d Translates an array of 2 dimensional vectors
+ * xlat2d
Translates an array of 2 dimensional vectors
*
* SYNOPSIS
* xlat2d (x, y, n, xoffset, yoffset)
*
* SYNOPSIS
* xlat2d (x, y, n, xoffset, yoffset)
- * double x[], y[] Array of points
- * int n Number of points in array
- * double xoffset, yoffset Offset to translate points by
+ * double x[], y[]
Array of points
+ * int n
Number of points in array
+ * double xoffset, yoffset
Offset to translate points by
*/
*/
-void
+void
xlat2d (double x[], double y[], int n, double xoffset, double yoffset)
{
for (int i = 0; i < n; i++) {
xlat2d (double x[], double y[], int n, double xoffset, double yoffset)
{
for (int i = 0; i < n; i++) {
@@
-67,16
+65,16
@@
xlat2d (double x[], double y[], int n, double xoffset, double yoffset)
/* NAME
/* NAME
- * scale2d Scale an array of 2 dimensional vectors
+ * scale2d
Scale an array of 2 dimensional vectors
*
* SYNOPSIS
* scale2d (x, y, n, xoffset, yoffset)
*
* SYNOPSIS
* scale2d (x, y, n, xoffset, yoffset)
- * double x[], y[] Array of points
- * int n Number of points in array
- * double xfact, yfact x & y scaling factors
+ * double x[], y[]
Array of points
+ * int n
Number of points in array
+ * double xfact, yfact
x & y scaling factors
*/
*/
-void
+void
scale2d (double x[], double y[], int n, double xfact, double yfact)
{
for (int i = 0; i < n; i++) {
scale2d (double x[], double y[], int n, double xfact, double yfact)
{
for (int i = 0; i < n; i++) {
@@
-86,7
+84,7
@@
scale2d (double x[], double y[], int n, double xfact, double yfact)
}
}
-void
+void
indent_mtx2 (GRFMTX_2D m)
{
m[0][0] = 1.0; m[0][1] = 0.0; m[0][2] = 0.0;
indent_mtx2 (GRFMTX_2D m)
{
m[0][0] = 1.0; m[0][1] = 0.0; m[0][2] = 0.0;
@@
-94,7
+92,7
@@
indent_mtx2 (GRFMTX_2D m)
m[2][0] = 0.0; m[2][1] = 0.0; m[2][2] = 1.0;
}
m[2][0] = 0.0; m[2][1] = 0.0; m[2][2] = 1.0;
}
-void
+void
xlat_mtx2 (GRFMTX_2D m, const double x, const double y)
{
indent_mtx2 (m);
xlat_mtx2 (GRFMTX_2D m, const double x, const double y)
{
indent_mtx2 (m);
@@
-102,7
+100,7
@@
xlat_mtx2 (GRFMTX_2D m, const double x, const double y)
m[2][1] = y;
}
m[2][1] = y;
}
-void
+void
scale_mtx2 (GRFMTX_2D m, const double sx, const double sy)
{
indent_mtx2 (m);
scale_mtx2 (GRFMTX_2D m, const double sx, const double sy)
{
indent_mtx2 (m);
@@
-110,7
+108,7
@@
scale_mtx2 (GRFMTX_2D m, const double sx, const double sy)
m[1][1] = sy;
}
m[1][1] = sy;
}
-void
+void
rot_mtx2 (GRFMTX_2D m, const double theta)
{
double c = cos(theta);
rot_mtx2 (GRFMTX_2D m, const double theta)
{
double c = cos(theta);
@@
-121,25
+119,30
@@
rot_mtx2 (GRFMTX_2D m, const double theta)
m[1][0] = -s; m[1][1] = c;
}
m[1][0] = -s; m[1][1] = c;
}
-void
-mult_mtx2 (GRFMTX_2D m1, GRFMTX_2D m2, GRFMTX_2D result)
+void
+copy_mtx2 (GRFMTX_2D to, const GRFMTX_2D from) {
+ for (int r = 0; r < 3; r++)
+ for (int c = 0; c < 3; c++)
+ to[r][c] = from[r][c];
+}
+
+void
+mult_mtx2 (const GRFMTX_2D m1, const GRFMTX_2D m2, GRFMTX_2D result)
{
GRFMTX_2D temp;
{
GRFMTX_2D temp;
- for (int row = 0; row < 3; row++)
+ for (int row = 0; row < 3; row++)
{
for (int col = 0; col < 3; col++) {
temp[row][col] = 0;
for (int calc = 0; calc < 3; calc++)
for (int col = 0; col < 3; col++) {
temp[row][col] = 0;
for (int calc = 0; calc < 3; calc++)
- temp[row][col] += m1[row][calc] * m2[calc][col];
+
temp[row][col] += m1[row][calc] * m2[calc][col];
}
}
-
- for (int row = 0; row < 3; row++)
- for (int col = 0; col < 3; col++)
- result[row][col] = temp[row][col];
+ }
+ copy_mtx2 (result, temp);
}
}
-void
-xform_mtx2 (GRFMTX_2D m, double& x, double& y)
+void
+xform_mtx2 (
const
GRFMTX_2D m, double& x, double& y)
{
double xt = x * m[0][0] + y * m[1][0] + m[2][0];
double yt = x * m[0][1] + y * m[1][1] + m[2][1];
{
double xt = x * m[0][0] + y * m[1][0] + m[2][0];
double yt = x * m[0][1] + y * m[1][1] + m[2][1];