00001 /* 00002 * Copyright (C) 2007 David Churches, Jolien Creighton, Thomas Cokelaer 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with with program; see the file COPYING. If not, write to the 00016 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00017 * MA 02111-1307 USA 00018 */ 00019 00020 /* <lalVerbatim file="LALRectangleVerticesCV"> 00021 Author: Sathyaprakash, B. S. 00022 $Id: LALRectangleVertices.c,v 1.5 2007/06/08 14:41:42 bema Exp $ 00023 </lalVerbatim> */ 00024 00025 /* <lalLaTeX> 00026 00027 \subsection{Module \texttt{LALRectangleVertices.c}} 00028 00029 Module to find the vertices of a rectangle given its centre, 00030 half side-lengths and orientation angle. 00031 00032 \subsubsection*{Prototypes} 00033 \vspace{0.1in} 00034 \input{LALRectangleVerticesCP} 00035 \index{\verb&LALRectangleVertices()&} 00036 \begin{itemize} 00037 \item \texttt{out,} Output. 00038 \item \texttt{in,} Input. 00039 \end{itemize} 00040 00041 \subsubsection*{Description} 00042 00043 This code computes the vertices of a rectangle for plotting 00044 a grid of templates with xmgr, useful when looking at the 00045 minimal-match-rectangles around mesh points in a template bank. 00046 00047 \subsubsection*{Algorithm} 00048 Given the centre $(x_0,y_0)$ and half-sides $(dx,dy),$ 00049 the vertices of a rectangle in a {\it diagonal} coordinate 00050 system are given by 00051 \begin{eqnarray} 00052 x_1 & = & x_0 - dx, \ \ y_1 = y_0 - dy, \nonumber \\ 00053 x_2 & = & x_0 + dx, \ \ y_2 = y_0 - dy, \nonumber \\ 00054 x_3 & = & x_0 + dx, \ \ y_3 = y_0 + dy, \nonumber \\ 00055 x_4 & = & x_0 - dx, \ \ y_4 = y_0 + dy. \nonumber 00056 \end{eqnarray} 00057 The coordinates of a rectangle oriented at an angle $\theta$ is 00058 found by using the formulas 00059 \begin{eqnarray} 00060 x' = x \cos(\theta) - y \sin(\theta),\nonumber \\ 00061 y' = y \cos(\theta) + x \sin(\theta).\nonumber 00062 \end{eqnarray} 00063 The function returns five coordinate points (1,2,3,4,1), 00064 and not just the four verticies, to help 00065 a plotting programme to complete the rectangle. 00066 00067 \subsubsection*{Uses} 00068 None. 00069 00070 \subsubsection*{Notes} 00071 00072 \vfill{\footnotesize\input{LALRectangleVerticesCV}} 00073 00074 </lalLaTeX> */ 00075 00076 #include <lal/LALInspiralBank.h> 00077 00078 NRCSID(LALRECTANGLEVERTICESC, "$Id: LALRectangleVertices.c,v 1.5 2007/06/08 14:41:42 bema Exp $"); 00079 00080 /* <lalVerbatim file="LALRectangleVerticesCP"> */ 00081 00082 void 00083 LALRectangleVertices( 00084 LALStatus *status, 00085 RectangleOut *out, 00086 RectangleIn *in 00087 ) 00088 { /* </lalVerbatim> */ 00089 00090 REAL4 x1, x2, x3, x4, myy1, y2, y3, y4; 00091 REAL4 ctheta,stheta; 00092 INITSTATUS(status, "LALRectangleVertices", LALRECTANGLEVERTICESC); 00093 ATTATCHSTATUSPTR(status); 00094 00095 ASSERT (out, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL); 00096 ASSERT (in, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL); 00097 00098 /* 00099 x1 = out->x1 = in->x0-in->dx/2.; 00100 myy1 = out->y1 = in->y0-in->dy/2.; 00101 x2 = out->x2 = in->x0+in->dx/2.; 00102 y2 = out->y2 = in->y0-in->dy/2.; 00103 x3 = out->x3 = in->x0+in->dx/2.; 00104 y3 = out->y3 = in->y0+in->dy/2.; 00105 x4 = out->x4 = in->x0-in->dx/2.; 00106 y4 = out->y4 = in->y0+in->dy/2.; 00107 00108 out->x1 = x1 * cos(in->theta) - myy1 * sin(in->theta); 00109 out->y1 = myy1 * cos(in->theta) + x1 * sin(in->theta); 00110 out->x2 = x2 * cos(in->theta) - y2 * sin(in->theta); 00111 out->y2 = y2 * cos(in->theta) + x2 * sin(in->theta); 00112 out->x3 = x3 * cos(in->theta) - y3 * sin(in->theta); 00113 out->y3 = y3 * cos(in->theta) + x3 * sin(in->theta); 00114 out->x4 = x4 * cos(in->theta) - y4 * sin(in->theta); 00115 out->y4 = y4 * cos(in->theta) + x4 * sin(in->theta); 00116 */ 00117 x1 = -in->dx/2.; 00118 myy1 = -in->dy/2.; 00119 x2 = in->dx/2.; 00120 y2 = -in->dy/2.; 00121 x3 = in->dx/2.; 00122 y3 = in->dy/2.; 00123 x4 = -in->dx/2.; 00124 y4 = in->dy/2.; 00125 ctheta=cos(in->theta); 00126 stheta=sin(in->theta); 00127 00128 out->x1 = in->x0 + x1 * ctheta - myy1 * stheta; 00129 out->y1 = in->y0 + myy1 * ctheta + x1 * stheta; 00130 out->x2 = in->x0 + x2 * ctheta - y2 * stheta; 00131 out->y2 = in->y0 + y2 * ctheta + x2 * stheta; 00132 out->x3 = in->x0 + x3 * ctheta - y3 * stheta; 00133 out->y3 = in->y0 + y3 * ctheta + x3 * stheta; 00134 out->x4 = in->x0 + x4 * ctheta - y4 * stheta; 00135 out->y4 = in->y0 + y4 * ctheta + x4 * stheta; 00136 00137 out->x5 = out->x1; 00138 out->y5 = out->y1; 00139 00140 DETATCHSTATUSPTR(status); 00141 RETURN(status); 00142 }
1.5.2