Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInspiral 5.0.3.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALRectangleVertices.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 David Churches, Jolien Creighton, 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#include <lal/LALInspiralBank.h>
21
22/**
23 * \ingroup LALInspiralBank_h
24 * \brief Function to find the vertices of a rectangle given its centre, half side-lengths and orientation angle.
25 * \author Sathyaprakash, B. S.
26 *
27 * This code computes the vertices of a rectangle for plotting
28 * a grid of templates with xmgr, useful when looking at the
29 * minimal-match-rectangles around mesh points in a template bank.
30 *
31 * ### Algorithm ###
32 *
33 * Given the centre \f$(x_0,y_0)\f$ and half-sides \f$(dx,dy),\f$
34 * the vertices of a rectangle in a \e diagonal coordinate
35 * system are given by
36 * \f{eqnarray}{
37 * x_1 & = & x_0 - dx, \quad y_1 = y_0 - dy, \\
38 * x_2 & = & x_0 + dx, \quad y_2 = y_0 - dy, \\
39 * x_3 & = & x_0 + dx, \quad y_3 = y_0 + dy, \\
40 * x_4 & = & x_0 - dx, \quad y_4 = y_0 + dy.
41 * \f}
42 * The coordinates of a rectangle oriented at an angle \f$\theta\f$ is
43 * found by using the formulas
44 * \f{eqnarray}{
45 * x' = x \cos(\theta) - y \sin(\theta), \\
46 * y' = y \cos(\theta) + x \sin(\theta).
47 * \f}
48 * The function returns five coordinate points (1,2,3,4,1),
49 * and not just the four verticies, to help
50 * a plotting programme to complete the rectangle.
51 */
52void
54 LALStatus *status, /**< LAL status pointer */
55 RectangleOut *out, /**< Output */
56 RectangleIn *in /**< Input */
57)
58{
59
60 REAL4 x1, x2, x3, x4, myy1, y2, y3, y4;
61 REAL4 ctheta,stheta;
64
65 ASSERT (out, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
66 ASSERT (in, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
67
68/*
69 x1 = out->x1 = in->x0-in->dx/2.;
70 myy1 = out->y1 = in->y0-in->dy/2.;
71 x2 = out->x2 = in->x0+in->dx/2.;
72 y2 = out->y2 = in->y0-in->dy/2.;
73 x3 = out->x3 = in->x0+in->dx/2.;
74 y3 = out->y3 = in->y0+in->dy/2.;
75 x4 = out->x4 = in->x0-in->dx/2.;
76 y4 = out->y4 = in->y0+in->dy/2.;
77
78 out->x1 = x1 * cos(in->theta) - myy1 * sin(in->theta);
79 out->y1 = myy1 * cos(in->theta) + x1 * sin(in->theta);
80 out->x2 = x2 * cos(in->theta) - y2 * sin(in->theta);
81 out->y2 = y2 * cos(in->theta) + x2 * sin(in->theta);
82 out->x3 = x3 * cos(in->theta) - y3 * sin(in->theta);
83 out->y3 = y3 * cos(in->theta) + x3 * sin(in->theta);
84 out->x4 = x4 * cos(in->theta) - y4 * sin(in->theta);
85 out->y4 = y4 * cos(in->theta) + x4 * sin(in->theta);
86*/
87 x1 = -in->dx/2.;
88 myy1 = -in->dy/2.;
89 x2 = in->dx/2.;
90 y2 = -in->dy/2.;
91 x3 = in->dx/2.;
92 y3 = in->dy/2.;
93 x4 = -in->dx/2.;
94 y4 = in->dy/2.;
95 ctheta=cos(in->theta);
96 stheta=sin(in->theta);
97
98 out->x1 = in->x0 + x1 * ctheta - myy1 * stheta;
99 out->y1 = in->y0 + myy1 * ctheta + x1 * stheta;
100 out->x2 = in->x0 + x2 * ctheta - y2 * stheta;
101 out->y2 = in->y0 + y2 * ctheta + x2 * stheta;
102 out->x3 = in->x0 + x3 * ctheta - y3 * stheta;
103 out->y3 = in->y0 + y3 * ctheta + x3 * stheta;
104 out->x4 = in->x0 + x4 * ctheta - y4 * stheta;
105 out->y4 = in->y0 + y4 * ctheta + x4 * stheta;
106
107 out->x5 = out->x1;
108 out->y5 = out->y1;
109
111 RETURN(status);
112}
#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 LALRectangleVertices(LALStatus *status, RectangleOut *out, RectangleIn *in)
Function to find the vertices of a rectangle given its centre, half side-lengths and orientation angl...
Input structure to function LALRectangleVertices()
Output structure to function LALRectangleVertices().