GithubHelp home page GithubHelp logo

astro.js's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently working part-time at Open Innovations
  • ๐Ÿ’ฌ Ask me about astronomy
  • ๐Ÿ“ซ How to reach me: @ slowe @ mastodon.me.uk
  • ๐Ÿ”— Website: strudel.org.uk
  • ๐Ÿ˜„ Pronouns: He/him
  • โšก Fun fact: I helped build instruments that travelled 1.5 million kilometres from Earth

astro.js's People

Contributors

slowe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astro.js's Issues

error in astrojs.coordinates.ecliptic2azel

Hi!
I tried to use your astro.js lib but when I call
var sunazel = astrojs.coordinates.ecliptic2azel(sunpos.lat, sunpos.lon, lst, lat);
I get the error
SCRIPT438: Object doesn't support property or method 'vectorMultiply'
Did I something wrong? All parameters are numeric values!
Thanks
Peter


<!DOCTYPE html>
<html>

<!-- astro.js : http://slowe.github.io/astro.js/ -->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

</style>

<script language="javascript" type="text/javascript" src="astro.js/astro.js"></script>
<script language="javascript" type="text/javascript" src="astro.js/astro.dates.js"></script> <!-- JD, GST, LST -->
<script language="javascript" type="text/javascript" src="astro.js/astro.ephem.js"></script> <!-- sunPos, moonPos -->
<script language="javascript" type="text/javascript" src="astro.js/astro.coords.js"></script> <!-- coordinates and value transformation -->
<script language="javascript" type="text/javascript" src="astro.js/astro.coordinates.js"></script> <!-- coordinates and value transformation -->
<script language="javascript" type="text/javascript">

var lng = 48.12;
var lat = -16.32;
var tz  = -1;

function initAstro() {
	//astrojs.ready(function(e){ });
	// ...
	doAstro();
	return;
}

function doAstro() {
	var txt = "";
	var dt = new Date();
	txt += dt + "<br>\n";
	var jd = astrojs.dates.getJulianDate(dt);
	txt += "Julian Date (JD) : " + jd + "<br>\n";
	txt += "Greenwich Sidereal Time (GST) : " + astrojs.dates.getGST(dt) + "<br>\n";
	var lst = astrojs.dates.getLST(dt, lng);
	txt += "Local Sidereal Time (LST) : " + lst + "<br>\n";
	var sunpos = astrojs.ephem.sunPos(jd);
	txt += "Sun Pos : lat:" + sunpos.lat + "  lon:" + sunpos.lon + "  Mo:" + sunpos.Mo + 
		"  D:" + sunpos.D + "  N:" + sunpos.N + "<br>\n";
	var sunazel = astrojs.coordinates.ecliptic2azel(sunpos.lat, sunpos.lon, lst, lat);   // <<<< ERROR
	txt += "Sun Pos : az:" + sunazel.az + "  el:" + sunazel.el + "<br>\n";
	var moonpos = astrojs.ephem.moonPos(jd, sunpos);
	txt += "Moon Pos : lat:" + moonpos.lat + "  lon:" + moonpos.lon + "<br>\n";
	txt += "mean Obliquity : " + astrojs.coordinates.meanObliquity(jd) + "<br>\n";

	document.getElementById("output").innerHTML = txt;
	return;
}


</script>

</head>

<body onload="initAstro()">

<form name="astro" action="#" onsubmit="doAstro();">
	<button onclick="doAstro();">submit</button>
</form>
<br><br>
Result:<br>
<p id="output">*</p>


</body>
</html>

[Help Wanted] Moon Phase computation

Hi,

First of all, thanks for your library. I am not exploring yet, but it's definitively quite something !

Using your library, I am trying to reproduce the following moon phase indicator : http://www.patek.com/en/collection/movements-complications/moonphase-indicator

For now, I've something like this:

    this.illum = this.getMoonIllumination(new Date());
    this.pos = this.getMoonPosition(new Date(), 0, 0);
    this.angleMoon = this.illum.angle - this.pos.parallacticAngle;

Which gives me the actual moon position at Date() rather than the moon phase.

I've tried to adapt the calculation so they match this code by Xavier Jubier, without success:

/**
 * The following code is
 * Adapted from http://xjubier.free.fr/en/site_pages/LunarEclipseCalculator.html
 * Copyright Xavier Jubier
 */
var myPhaseName = "";
var forecastImage = new Array();

function moonPhasePercent(theDate)
{
  var synodic = 29.53058867;
  var msPerDay = 86400000;
  var baseDate = new Date();
  baseDate.setUTCFullYear(2005);
  baseDate.setUTCMonth(4);
  baseDate.setUTCDate(8);
  baseDate.setUTCHours(8);
  baseDate.setUTCMinutes(48);

  var diff = theDate - baseDate;
  var phase = diff / (synodic * msPerDay);
  phase *= 100;
  phase %= 100;
  if ( phase < 0 )
    phase += 100;

  return(phase);
}

function getMoonPhase()
{

  var theDate = new Date();

  var phasePercent = moonPhasePercent(theDate);

  var phaseNames = [
    "New Moon", "New Moon",
    "Waxing Crescent", "Waxing Crescent", "Waxing Crescent", "Waxing Crescent",
    "First Quarter", "First Quarter", "First Quarter",
    "Waxing Gibbous", "Waxing Gibbous", "Waxing Gibbous", "Waxing Gibbous", "Waxing Gibbous",
    "Full Moon", "Full Moon",
    "Waning Gibbous", "Waning Gibbous", "Waning Gibbous", "Waning Gibbous",
    "Last Quarter", "Last Quarter", "Last Quarter",
    "Waning Crescent", "Waning Crescent", "Waning Crescent", "Waning Crescent",
    "New Moon"
  ];

  thePhase = Math.round(phasePercent * 0.279);
  myPhaseName = phaseNames[thePhase];

  return thePhase;
}

Thanks,
M.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.