diff --git a/examples/basic.js b/examples/basic.js index 8412f0a..48db4e8 100644 --- a/examples/basic.js +++ b/examples/basic.js @@ -5,11 +5,45 @@ Swe.init(); var timestamp = new Swe.Timestamp(); timestamp.set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1); -moment = new Swe.Moment(); +var moment = new Swe.Moment(); moment.add_all_planets(); moment.set_timestamp(timestamp); moment.set_coordinates(19.03990999, 47.49801000, 280); moment.set_house_system(Swe.HouseSystem.PLACIDUS); -planet = moment.get_planet(Swe.Planet.SUN); -log(planet.get_position()); +var all_planets = moment.get_all_planets() +for (var i = 0; i < all_planets.length; i++) { + var planet = all_planets[i]; + var position = planet.get_position(); + var sign_position = position % 30; + var degree = Math.floor(sign_position); + var minute = Math.floor((sign_position - degree) * 60); + var second = Math.floor(((sign_position - degree) * 60 - minute) * 60) + + log(planet.get_planet_info().get_name() + ": " + position + " (" + degree + "°" + minute + "′" + second + "″ " + planet.get_sign_info().get_name() + ")"); +} + +var all_aspects = moment.get_all_aspects(); +for (var i = 0; i < all_aspects.length; i++) { + var aspect = all_aspects[i]; + + if (aspect.get_aspect() != Swe.Aspect.NONE) { + var planet1 = aspect.get_planet1(); + var planet2 = aspect.get_planet2(); + + log(planet1.get_planet_info().get_name() + " in " + aspect.get_aspect_info().get_name() + " with " + planet2.get_planet_info().get_name() + "(±" + aspect.get_difference() + "%)"); + } +} + +var all_antiscia = moment.get_all_antiscia(); +for (var i = 0; i < all_antiscia.length; i++) { + var antiscion = all_antiscia[i]; + + if (antiscion.get_axis() != Swe.AntiscionAxis.NONE) { + var planet1 = antiscion.get_planet1(); + var planet2 = antiscion.get_planet2(); + + log(planet1.get_planet_info().get_name() + " is antiscion of " + planet2.get_planet_info().get_name() + " on axis " + antiscion.get_antiscion_axis_info().get_name() + " (±" + antiscion.get_difference() + "%)"); + } +} + diff --git a/examples/basic.pl b/examples/basic.pl index 28ee51f..c0a86a5 100644 --- a/examples/basic.pl +++ b/examples/basic.pl @@ -1,21 +1,54 @@ package SweGlib; +use strict; +use POSIX; use Glib::Object::Introspection; +use Data::Dumper; + Glib::Object::Introspection->setup(basename => 'SweGlib', version => '2.0', package => 'SweGlib'); package main; SweGlib::init(); -$timestamp = SweGlib::Timestamp->new(); +my $timestamp = SweGlib::Timestamp->new(); $timestamp->set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1); -$moment = SweGlib::Moment->new(); +my $moment = SweGlib::Moment->new(); $moment->set_timestamp($timestamp); $moment->set_coordinates(19.0390999, 47.49801000, 280); $moment->set_house_system("placidus"); $moment->add_all_planets(); -$planet = $moment->get_planet("sun"); -print($planet->get_position(), "\n"); +my $all_planets = $moment->get_all_planets(); +foreach my $planet (@{$all_planets}) { + my $position = $planet->get_position(); + my $sign_position = POSIX::fmod($position, 30); + my $degree = POSIX::floor($sign_position); + my $minute = POSIX::floor(($sign_position - $degree) * 60); + my $second = POSIX::floor((($sign_position - $degree) * 60 - $minute) * 60); + + printf("%s: %f (%d°%d′%d″ %s)\n", $planet->get_planet_info()->get_name(), $position, $degree, $minute, $second, $planet->get_sign_info()->get_name()); +} + +my $all_aspects = $moment->get_all_aspects(); +foreach my $aspect (@{$all_aspects}) { + if ($aspect->get_aspect() ne "none") { + my $planet1 = $aspect->get_planet1(); + my $planet2 = $aspect->get_planet2(); + + printf("%s in %s with %s (±%.2f%%)\n", $planet1->get_planet_info()->get_name(), $aspect->get_aspect_info->get_name(), $planet2->get_planet_info()->get_name(), $aspect->get_difference()); + } +} + +my $all_antiscia = $moment->get_all_antiscia(); +foreach my $antiscion (@{$all_antiscia}) { + if ($antiscion->get_axis() ne "none") { + my $planet1 = $antiscion->get_planet1(); + my $planet2 = $antiscion->get_planet2(); + + printf("%s is antiscion of %s on axis %s (±%.2f%%)\n", $planet1->get_planet_info()->get_name(), $planet2->get_planet_info()->get_name(), $antiscion->get_antiscion_axis_info()->get_name(), $antiscion->get_difference()); + } +} + diff --git a/examples/basic.py b/examples/basic.py index 414a219..5663329 100644 --- a/examples/basic.py +++ b/examples/basic.py @@ -1,4 +1,6 @@ +# -*- coding: utf-8 -*- from gi.repository import SweGlib +import math SweGlib.init() @@ -13,18 +15,27 @@ moment.add_all_planets() all_planets = moment.get_all_planets() for planet in all_planets: - print "%s: %f" % (planet.get_planet_info().get_name(), planet.get_position()) + position = planet.get_position() + sign_position = position % 30 + degree = math.floor(sign_position) + minute = math.floor((sign_position - degree) * 60) + second = math.floor(((sign_position - degree) * 60 - minute) * 60) + + print u"%s: %f (%d°%d′%d″ %s)" % (planet.get_planet_info().get_name(), position, degree, minute, second, planet.get_sign_info().get_name()) all_aspects = moment.get_all_aspects() for aspect in all_aspects: if aspect.get_aspect() != SweGlib.Aspect.NONE: planet1 = aspect.get_planet1() planet2 = aspect.get_planet2() - print "%s in %s with %s" % (planet1.get_planet_info().get_name(), aspect.get_aspect_info().get_name(), planet2.get_planet_info().get_name()) + + print u"%s in %s with %s (±%.2f%%)" % (planet1.get_planet_info().get_name(), aspect.get_aspect_info().get_name(), planet2.get_planet_info().get_name(), aspect.get_difference()) all_antiscia = moment.get_all_antiscia() for antiscion in all_antiscia: if antiscion.get_axis() != SweGlib.AntiscionAxis.NONE: planet1 = antiscion.get_planet1() planet2 = antiscion.get_planet2() - print "%s is antiscion of %s on axis %s" % (planet1.get_planet_info().get_name(), planet2.get_planet_info().get_name(), antiscion.get_antiscion_axis_info().get_name()) + + print "%s is antiscion of %s on axis %s (±%.2f%%)" % (planet1.get_planet_info().get_name(), planet2.get_planet_info().get_name(), antiscion.get_antiscion_axis_info().get_name(), antiscion.get_difference()) +