00001 /* 00002 * Copyright (C) 2007 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="LALHexagonVerticesCV"> 00021 Author: Cokelaer Thomas. 00022 $Id: LALHexagonVertices.c,v 1.2 2007/06/08 14:41:42 bema Exp $ 00023 </lalVerbatim> */ 00024 00025 /* <lalLaTeX> 00026 00027 \subsection{Module \texttt{LALHexagonVertices.c}} 00028 00029 Module to find the vertices of an hexagon inscribed in an ellipse 00030 given its centre, half side-lengths and orientation angle. 00031 00032 \subsubsection*{Prototypes} 00033 \vspace{0.1in} 00034 \input{LALRectangleVerticesCP} 00035 \index{\verb&LALHexagonVertices()&} 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 an hexagon for plotting 00044 a grid of templates with xmgr, useful when looking at the 00045 minimal-match-Hexagons around mesh points in a template bank. 00046 Used by SpaceCovering in the test directory. 00047 00048 \subsubsection*{Algorithm} 00049 Given the centre $(x_0,y_0)$ and half-sides $(dx,dy),$ 00050 the vertices of a Hexagon in a {\it diagonal} coordinate 00051 system are given by 00052 \begin{eqnarray} 00053 x_1 & = & x_0 - dx, \ \ y_1 = y_0 - dy, \nonumber \\ 00054 x_2 & = & x_0 + dx, \ \ y_2 = y_0 - dy, \nonumber \\ 00055 x_3 & = & x_0 + dx, \ \ y_3 = y_0 + dy, \nonumber \\ 00056 x_4 & = & x_0 - dx, \ \ y_4 = y_0 + dy. \nonumber 00057 \end{eqnarray} 00058 The coordinates of a Hexagon oriented at an angle $\theta$ is 00059 found by using the formulas 00060 \begin{eqnarray} 00061 x' = x \cos(\theta) - y \sin(\theta),\nonumber \\ 00062 y' = y \cos(\theta) + x \sin(\theta).\nonumber 00063 \end{eqnarray} 00064 The function returns 7 coordinate points (1,2,3,4,5,6,1), 00065 and not just the 6 verticies, to help a plotting programme 00066 to complete the Hexagon. 00067 00068 \subsubsection*{Uses} 00069 None. 00070 00071 \subsubsection*{Notes} 00072 00073 \vfill{\footnotesize\input{LALHexagonVerticesCV}} 00074 00075 </lalLaTeX> */ 00076 00077 #include <lal/LALInspiralBank.h> 00078 00079 NRCSID(LALHEXAGONVERTICESC, "$Id: LALHexagonVertices.c,v 1.2 2007/06/08 14:41:42 bema Exp $"); 00080 00081 /* <lalVerbatim file="LALHexagonVerticesCP"> */ 00082 00083 void 00084 LALHexagonVertices( 00085 LALStatus *status, 00086 HexagonOut *out, 00087 RectangleIn *in 00088 ) 00089 { /* </lalVerbatim> */ 00090 00091 REAL4 x1, x2, x3, x4, y1, y2, y3, y4, x5, y5, x6, y6, x7, y7; 00092 REAL4 ctheta,stheta, sca; 00093 INITSTATUS(status, "LALHexagonVertices", LALHEXAGONVERTICESC); 00094 ATTATCHSTATUSPTR(status); 00095 00096 ASSERT (out, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL); 00097 ASSERT (in, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL); 00098 00099 sca = sqrt(3); 00100 00101 x1 = -in->dx/2; 00102 y1 = -in->dy/sca/2; 00103 x2 = 0; 00104 y2 = -in->dy/sqrt(3); 00105 x3 = in->dx/2; 00106 y3 = -in->dy/sca/2; 00107 x4 = in->dx/2; 00108 y4 = in->dy/sca/2; 00109 x5 = 0; 00110 y5 = in->dy/sqrt(3); 00111 x6 = -in->dx/2; 00112 y6 = in->dy/sca/2; 00113 00114 ctheta=cos(in->theta); 00115 stheta=sin(in->theta); 00116 00117 out->x1 = in->x0 + x1 * ctheta - y1 * stheta; 00118 out->y1 = in->y0 + y1 * ctheta + x1 * stheta; 00119 out->x2 = in->x0 + x2 * ctheta - y2 * stheta; 00120 out->y2 = in->y0 + y2 * ctheta + x2 * stheta; 00121 out->x3 = in->x0 + x3 * ctheta - y3 * stheta; 00122 out->y3 = in->y0 + y3 * ctheta + x3 * stheta; 00123 out->x4 = in->x0 + x4 * ctheta - y4 * stheta; 00124 out->y4 = in->y0 + y4 * ctheta + x4 * stheta; 00125 out->x5 = in->x0 + x5 * ctheta - y5 * stheta; 00126 out->y5 = in->y0 + y5 * ctheta + x5 * stheta; 00127 out->x6 = in->x0 + x6 * ctheta - y6 * stheta; 00128 out->y6 = in->y0 + y6 * ctheta + x6 * stheta; 00129 00130 out->x7 = out->x1; 00131 out->y7 = out->y1; 00132 DETATCHSTATUSPTR(status); 00133 RETURN(status); 00134 }
1.5.2