Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInspiral 5.0.3.1-6c6b863
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALHexagonVertices.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Thomas Cokelaer
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/**
21 * \author Cokelaer Thomas.
22 * \file
23 *
24 * \brief Module to find the vertices of an hexagon inscribed in an ellipse
25 * given its centre, half side-lengths and orientation angle.
26 *
27 * ### Prototypes ###
28 *
29 * <tt>LALHexagonVertices()</tt>
30 * <ul>
31 * <li> <tt>out,</tt> Output.
32 * </li><li> <tt>in,</tt> Input.</li>
33 * </ul>
34 *
35 * ### Description ###
36 *
37 * This code computes the vertices of an hexagon for plotting
38 * a grid of templates with xmgr, useful when looking at the
39 * minimal-match-Hexagons around mesh points in a template bank.
40 * Used by SpaceCovering in the test directory.
41 *
42 * ### Algorithm ###
43 *
44 * Given the centre \f$(x_0,y_0)\f$ and half-sides \f$(dx,dy),\f$
45 * the vertices of a Hexagon in a \e diagonal coordinate
46 * system are given by
47 * \f{eqnarray}{
48 * x_1 & = & x_0 - dx, \quad y_1 = y_0 - dy, \\
49 * x_2 & = & x_0 + dx, \quad y_2 = y_0 - dy, \\
50 * x_3 & = & x_0 + dx, \quad y_3 = y_0 + dy, \\
51 * x_4 & = & x_0 - dx, \quad y_4 = y_0 + dy.
52 * \f}
53 * The coordinates of a Hexagon oriented at an angle \f$\theta\f$ is
54 * found by using the formulas
55 * \f{eqnarray}{
56 * x' = x \cos(\theta) - y \sin(\theta), \\
57 * y' = y \cos(\theta) + x \sin(\theta).
58 * \f}
59 * The function returns 7 coordinate points (1,2,3,4,5,6,1),
60 * and not just the 6 verticies, to help a plotting programme
61 * to complete the Hexagon.
62 *
63 * ### Uses ###
64 *
65 * None.
66 *
67 * ### Notes ###
68 *
69 */
70
71#include <lal/LALInspiralBank.h>
72
73void
76 HexagonOut *out,
77 RectangleIn *in
78)
79{
80
81 REAL4 x_1, x_2, x_3, x_4, x_5, x_6;
82 REAL4 y_1, y_2, y_3, y_4, y_5, y_6;
83 REAL4 ctheta,stheta, sca;
86
87 ASSERT (out, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
88 ASSERT (in, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
89
90 sca = sqrt(3);
91
92 x_1 = -in->dx/2;
93 y_1 = -in->dy/sca/2;
94 x_2 = 0;
95 y_2 = -in->dy/sqrt(3);
96 x_3 = in->dx/2;
97 y_3 = -in->dy/sca/2;
98 x_4 = in->dx/2;
99 y_4 = in->dy/sca/2;
100 x_5 = 0;
101 y_5 = in->dy/sqrt(3);
102 x_6 = -in->dx/2;
103 y_6 = in->dy/sca/2;
104
105 ctheta=cos(in->theta);
106 stheta=sin(in->theta);
107
108 out->x1 = in->x0 + x_1 * ctheta - y_1 * stheta;
109 out->y1 = in->y0 + y_1 * ctheta + x_1 * stheta;
110 out->x2 = in->x0 + x_2 * ctheta - y_2 * stheta;
111 out->y2 = in->y0 + y_2 * ctheta + x_2 * stheta;
112 out->x3 = in->x0 + x_3 * ctheta - y_3 * stheta;
113 out->y3 = in->y0 + y_3 * ctheta + x_3 * stheta;
114 out->x4 = in->x0 + x_4 * ctheta - y_4 * stheta;
115 out->y4 = in->y0 + y_4 * ctheta + x_4 * stheta;
116 out->x5 = in->x0 + x_5 * ctheta - y_5 * stheta;
117 out->y5 = in->y0 + y_5 * ctheta + x_5 * stheta;
118 out->x6 = in->x0 + x_6 * ctheta - y_6 * stheta;
119 out->y6 = in->y0 + y_6 * ctheta + x_6 * stheta;
120
121 out->x7 = out->x1;
122 out->y7 = out->y1;
124 RETURN(status);
125}
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
float REAL4
#define LALINSPIRALBANKH_ENULL
Null pointer.
void LALHexagonVertices(LALStatus *status, HexagonOut *out, RectangleIn *in)
UNDOCUMENTED.
Input structure to function LALRectangleVertices()