source: trunk/src/FitsIO/Beam.cc @ 1441

Last change on this file since 1441 was 1069, checked in by MatthewWhiting, 12 years ago

Adding the licensing text to files that didn't have it.

File size: 2.5 KB
Line 
1// -----------------------------------------------------------------------
2// Beam.cc: Basic beam-handling functionality
3// -----------------------------------------------------------------------
4// Copyright (C) 2006, Matthew Whiting, ATNF
5//
6// This program is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// Duchamp is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14// for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Duchamp; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19//
20// Correspondence concerning Duchamp may be directed to:
21//    Internet email: Matthew.Whiting [at] atnf.csiro.au
22//    Postal address: Dr. Matthew Whiting
23//                    Australia Telescope National Facility, CSIRO
24//                    PO Box 76
25//                    Epping NSW 1710
26//                    AUSTRALIA
27// -----------------------------------------------------------------------
28#include <iostream>
29#include <math.h>
30#include <duchamp/FitsIO/Beam.hh>
31#include <duchamp/duchamp.hh>
32
33namespace duchamp
34{
35
36  Beam::Beam():
37    itsMaj(0), itsMin(0), itsPA(0), itsArea(0)
38  {
39  }
40
41  Beam::Beam(float maj, float min, float pa):
42    itsMaj(maj),itsMin(min),itsPA(pa)
43  {
44    this->calculateArea();
45  }
46
47  Beam::Beam(const Beam &b)
48  {
49    operator=(b);
50  }
51
52  Beam& Beam::operator=(const Beam &b)
53  {
54    if(this == &b ) return *this;
55    this->itsMaj = b.itsMaj;
56    this->itsMin = b.itsMin;
57    this->itsPA = b.itsPA;
58    this->itsArea = b.itsArea;
59    return *this;
60  }
61
62  void Beam::calculateArea()
63  {
64    this->itsArea =  M_PI * (this->itsMaj/2.) * (this->itsMin/2.) / M_LN2;
65  }
66
67  void Beam::areaToFWHM()
68  {
69    float fwhm = 2.*sqrt( this->itsArea * M_LN2 / M_PI );
70    this->itsMaj = fwhm;
71    this->itsMin = fwhm;
72    this->itsPA = 0.;
73  }
74
75  void Beam::define(float maj, float min, float pa)
76  {
77    this->itsMaj = maj;
78    this->itsMin = min;
79    this->itsPA  = pa;
80    this->calculateArea();
81  }
82
83  void Beam::setFWHM(float fwhm)
84  {
85    this->itsMaj = fwhm;
86    this->itsMin = fwhm;
87    this->itsPA = 0.;
88    this->calculateArea();
89  }
90
91  void Beam::setArea(float area)
92  {
93    this->itsArea = area;
94    this->areaToFWHM();
95  }
96
97
98}
Note: See TracBrowser for help on using the repository browser.