GSP
Quick Navigator

Search Site

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

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Astro::Coords::Angle(3) User Contributed Perl Documentation Astro::Coords::Angle(3)

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.

new
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.

radians
Return the angle in radians.

 $rad = $ang->radians;
    
degrees
Return the angle in decimal degrees.

 $deg = $ang->degrees;
    
str_ndp
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;
    
str_delim
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;
    
components
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.

string
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).

arcsec
Return the angle in arcseconds.

 $asec = $ang->arcsec;
    
arcmin
Return the angle in arcminutes.

 $amin = $ang->arcmin;
    
range
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.

in_format
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.

clone
Create new cloned copy of this object.

  $clone = $ang->clone;
    
negate
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.

The following methods control the default behaviour of the class.
NDP
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 );
    
DELIM
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.

to_radians
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 <t.jenness@cpan.org>

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

2022-04-08 perl v5.32.1

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

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