Git Product home page Git Product logo

rust-sun's Introduction

sun

A rust port of the JS library suncalc.

Build status

Install

Add the following to your Cargo.toml

[dependencies]
sun = "0.2"

Usage

pub fn main() {
  let unixtime = 1362441600000;
  let lat = 48.0;
  let lon = 9.0;
  let pos = sun::pos(unixtime,lat,lon);
  let az  = pos.azimuth.to_degrees();
  let alt = pos.altitude.to_degrees();
  println!("The position of the sun is {}/{}", az, alt);

  let time_ms = sun::time_at_phase(unixtime, sun::SunPhase::Sunrise, lat, lon, 0.0);
  println!("Sunrise is at {}", time_ms);
}

rust-sun's People

Contributors

flosse avatar markus-k 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rust-sun's Issues

Change unixtime_in_ms type

Hi!
Thank you for your crate! Nice to have this kind of calculations in rust! :)
I am now putting it into my project :)

I want to ask about one thing:
I think it is unable that unixtime_in_ms could be negative, what do you think?
In this case it would be probably better if you change it from i64 to u128.
And u128 is because the rust's Duration::as_millis() is returning u128 type.
So in this case we don't need to cast...

Look how I am obtaining the time:
https://stackoverflow.com/a/44378174

๐ŸŒ“ moon functions ๐ŸŒ—

Hello! I was looking into porting the moon functions from mourner/suncalc. Would you want those in this repo?

I've done the moon position function so far, and I noticed to you add PI to the azimuth in the rust version. Just curious why; I don't know anything about astronomy math :)

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.