Astro::Nova::EquPosn - Perl representation of a libnova ln_equ_posn


Astro-Nova documentation Contained in the Astro-Nova distribution.

Index


Code Index:

NAME

Top

Astro::Nova::EquPosn - Perl representation of a libnova ln_equ_posn

SYNOPSIS

Top

  use Astro::Nova qw(functions ...);
  my $date = Astro::Nova::EquPosn->new();
  $date->set_year(...);
  # ...
  print $date->as_ascii(), "\n";
  my @members = $date->get_all();

DESCRIPTION

Top

This class represents a libnova ln_equ_posn struct. The struct has the following layout:

  ln_equ_posn {
    double  ra  # right ascension
    double  dec # declination
  }

METHODS

Top

new

Constructor returns a new Astro::Nova::EquPosn. Optionally takes key/value pairs for setting the struct members. Extra arguments are ignored. Uninitialized struct members are set to zero.

get_... / set_...

Get or set any of the class attributes. (See list above)

get_all

Returns all members as a list.

set_all

Sets all members. Takes a list of values which must be in the order shown above. Any missing values are ignored, undefs are skipped.

as_ascii

Returns a human-readable ASCII table of the date information.

members

Returns a list of all members in order.

to_galactic_B1950 / to_galactic_J2000

Convert to galactic coordinates with respect to the B1950 or J2000 epochs (returns an Astro::Nova::GalPosn object).

from_galactic_B1950 / from_galactic_J2000

When called as a class method, creates a new Astro::Nova::EquPosn object from the given Astro::Nova::GalPosn object. Uses the B1950/J2000 epochs according to the method name.

When called as an object method, sets the current object's state instead.

SEE ALSO

Top

Astro::Nova

libnova website: http://libnova.sourceforge.net/

AUTHOR

Top

Steffen Mueller, <smueller@cpan.org>

COPYRIGHT AND LICENSE

Top


Astro-Nova documentation Contained in the Astro-Nova distribution.

package Astro::Nova::EquPosn;

use 5.008;
use strict;
use warnings;

use Astro::Nova;

# basic stuff is in Astro::Nova's XS!

sub members {
  return qw/ra dec/;
}

sub as_ascii {
  my $self = shift;
  my $template = <<'HERE';
Right Ascension:  %f
Declination:      %f
HERE
  return sprintf($template, $self->get_all());
}

sub get_all {
  my $self = shift;
  return(map $self->$_(), map "get_$_", $self->members());
}

sub set_all {
  my $self = shift;
  foreach my $member (map "set_$_", $self->members) {
    last if not @_;
    my $value = shift @_;
    next if not defined $value;
    $self->$member($value);
  }
  return 1;
}

sub from_galactic_B1950 {
  my $class = shift;
  my $obj = shift->to_equatorial_B1950();
  return $obj if not ref $class;
  $class->set_all($obj->get_all());
  return $class;
}

sub from_galactic_J2000 {
  my $class = shift;
  my $obj = shift->to_equatorial_J2000();
  return $obj if not ref $class;
  $class->set_all($obj->get_all());
  return $class;
}

sub to_galactic_B1950 {
  return Astro::Nova::get_gal_from_equ(shift);
}

sub to_galactic_J2000 {
  return Astro::Nova::get_gal_from_equ2000(shift);
}


1;
__END__