Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  ASTRO::COORDS::ANGLE (3)

.ds Aq ’


Astro::Coords::Angle - Representation of an angle



  use Astro::Coords::Angle;

  $ang = new Astro::Coords::Angle( 45.5, units => deg );
  $ang = new Astro::Coords::Angle( "45:30:00", units => sexagesimal );

  $rad = $ang->radians;
  $deg = $ang->degrees;
  $asec = $ang->arcsec;
  $amin = $ang->arcmin;
  $string = $ang->string;


Helper class for Astro::Coords to represent an angle. Methods are provided for parsing angles in sexagesimal format and for returning angles in any desired format.



<B>newB> Construct a new Angle object. Must be called with an angle as first argument. Optional hash arguments can be supplied to specify, for example, the units of the supplied angle.

  $ang = new Astro::Coords::Angle( $angle,
                                   units => "degrees" );

Supported options are:

  units      - units of the supplied string or number
  range      - restricted range of the angle

Supported units are:

 sexagesimal - A string of format either dd:mm:ss or "dd mm ss"
               "dms" separators are also supported.
 degrees     - decimal degrees
 radians     - radians
 arcsec      - arc seconds (abbreviated form is as)
 arcmin      - arc minutes (abbreviated form is am)

The units can be abbreviated to the first 3 characters.

If the units are not supplied the default is to assume sexagesimal if the supplied string contains spaces or colons or the characters d, m or s, degrees if the supplied number is greater than 2*PI (6.28), and radians for all other values. Negative angles are supported.

The options for range are documented in the range method.

If the angle can not be decoded (if a string), the constructor will fail.

    Accessor Methods

<B>radiansB> Return the angle in radians.

 $rad = $ang->radians;

<B>degreesB> Return the angle in decimal degrees.

 $deg = $ang->degrees;

<B>str_ndpB> Number of decimal places to use when stringifying the object. Default is to use the global class value (see the NDP class method). Set to undef to revert to the class setting.

  $ang->str_ndp( 4 );
  $ndp = $ang->str_ndp;

<B>str_delimB> Delimiter to use between components when stringifying. Default is to use the global class value (see the DELIM class method). Set to undef to revert to the class setting.

  $ang->str_delim( ":" );
  $delim = $ang->str_delim;

<B>componentsB> Return an array of components that correspond to the sign, degrees, arcminutes and arcseconds of the angle. The sign will be either a ’+’ or ’-’ and is required to distinguish ’+0’ from ’-0’.

  @comp = $ang->components;

The number of decimal places in the seconds will not be constrained by the setting of str_ndp, but is constrained by an optional argument:

  @comp = $ang->components( $ndp );

Default resolution is 5 decimal places.

In scalar context, returns a reference to an array.

<B>stringB> Return the angle as a string in sexagesimal format (e.g. 12:30:52.4).

  $string = $ang->string();

The form of this string depends on the str_delim and str_ndp settings and on whether the angular range allows negative values (the sign will be dropped if the range is known to be positive).

<B>arcsecB> Return the angle in arcseconds.

 $asec = $ang->arcsec;

<B>arcminB> Return the angle in arcminutes.

 $amin = $ang->arcmin;

<B>rangeB> String describing the allowed range of the angle. Allowed values are

  NONE         - no pre-determined range
  2PI          - 0 to 2*PI radians (0 to 360 degrees)
  PI           - -PI to +PI radians (-180 to 180 degrees)

Any other strings will be ignored (and a warning issued if appropriate).

When a new value is provided, the angle is normalised to this range. Note that this is not always reversible (especially if reverting to NONE). The range can also be specified to the constructor.

Default is not to normalize the angle.

<B>in_formatB> Simple wrapper method to support the backwards compatibility interface in Astro::Coords when requesting an angle by using a string format rather than an explicit method.

  $angle = $ang->in_format( sexagesimal );

Supported formats are:

  radians       calls radians method
  degrees       calls degrees method
  sexagesimal   calls string method
  array         calls components method (returns 2 dp resolution)
  arcsec        calls arcsec method
  arcmin        calls arcmin method

The format can be abbreviated to the first 3 letters, or ’am’ or ’as’ for arcmin and arcsec respectively. If no format is specified explicitly, the object itself will be returned.

<B>cloneB> Create new cloned copy of this object.

  $clone = $ang->clone;

<B>negateB> Negate the sense of the angle, returning a new angle object.

  $neg = $ang->negate;

Not allowed if the range is defined as 0 to 2PI.


The object is overloaded such that it stringifies via the string method, and returns the angle in radians in numify context.

    Class Methods

The following methods control the default behaviour of the class.
<B>NDPB> The number of decimal places to use in the fractional part of the number when stringifying (from either the string method or the components method).

  Astro::Coords::Angle->NDP( 4 );

Default value is 2. If this is changed then all instances will be affected on stringification unless the str_ndp attribute has been set explicitly for an instance.

If an undefined argument is supplied, the class will revert to its initial state.

  Astro::Coords::Angle->NDP( undef );

<B>DELIMB> Delimiter to use to separate components of a sexagesimal triplet when the object is stringified. If this is changed then all instances will be affected on stringification unless the str_delim attribute has been set explicitly for an instance.

Common values are a colon (12:52:45.4) or a space (12 52 45.4). If more than one character is present in the string, each character will be used in turn as a delimiter in the string until either no more gaps are present (or characters have been exhausted. In the former, if there are more characters than gaps, the first character remaining in the string will be appended, in the latter case, no more characters will be printed. For example, dms would result in ’12d52m45.4s’, whereas ’dm’ would result in ’12d52m45.4’

  Astro::Coords::Angle->DELIM( : );

Default is :. An undefined argument will result in the class reverting to the default state.

<B>to_radiansB> Low level utility routine to convert an input value in specified format to radians. This method uses the same code as the object constructor to parse the supplied input argument but does not require the overhead of object construction if the result is only to be used transiently.

  $rad = Astro::Coords::Angle->to_radians( $string, $format );

See the constructor documentation for the supported format strings.


Tim Jenness <>


Copyright (C) 2004-2005 Tim Jenness. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,Suite 330, Boston, MA 02111-1307, USA

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 ASTRO::COORDS::ANGLE (3) 2016-04-03

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.