/*****************************************************************************
** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
+** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: xform.cpp,v 1.4 2000/12/04 04:44:03 kevin Exp $
+** $Id$
**
** 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
/* NAME
- * rotate2d Rotates an array of 2 dimensional vectors
+ * rotate2d Rotates an array of 2 dimensional vectors
*
* 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);
/* NAME
- * xlat2d Translates an array of 2 dimensional vectors
+ * xlat2d Translates an array of 2 dimensional vectors
*
* 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++) {
/* NAME
- * scale2d Scale an array of 2 dimensional vectors
+ * scale2d Scale an array of 2 dimensional vectors
*
* 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++) {
}
-void
+void
indent_mtx2 (GRFMTX_2D m)
{
m[0][0] = 1.0; m[0][1] = 0.0; m[0][2] = 0.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);
m[2][1] = y;
}
-void
+void
scale_mtx2 (GRFMTX_2D m, const double sx, const double sy)
{
indent_mtx2 (m);
m[1][1] = sy;
}
-void
+void
rot_mtx2 (GRFMTX_2D m, const double theta)
{
double c = cos(theta);
m[1][0] = -s; m[1][1] = c;
}
-void
+void
mult_mtx2 (const GRFMTX_2D m1, const GRFMTX_2D m2, GRFMTX_2D result)
{
GRFMTX_2D temp;
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];
- }\r
- }\r
-\r
+ temp[row][col] += m1[row][calc] * m2[calc][col];
+ }
+ }
+
for (int r = 0; r < 3; r++)
for (int col = 0; col < 3; col++)
result[r][col] = temp[r][col];
}
-void
+void
xform_mtx2 (const GRFMTX_2D m, double& x, double& y)
{
double xt = x * m[0][0] + y * m[1][0] + m[2][0];