Code Monkey home page Code Monkey logo

Comments (4)

pk-acl avatar pk-acl commented on June 10, 2024

The error happens, because on the calculation of Astronomical.correctedHourAngle for sunrise with the coordinates given, the value passed to calculate degree is -1.0000000008014773. This is impossible to achieve hence error occurs.

from adhan-dart.

alhamri avatar alhamri commented on June 10, 2024

The error happens, because on the calculation of Astronomical.correctedHourAngle for sunrise with the coordinates given, the value passed to calculate degree is -1.0000000008014773. This is impossible to achieve hence error occurs.

yes the bug is there. I tried to solve it in the plugin by checking the value passed to acos function:
if it is less than -1, assign -1 to the value
if it is greater than 1, assign 1 to the value.

snippet code (before changing):

final term1 = sin(radians(h0)) -
        (sin(radians(coordinates.latitude)) * sin(radians(delta2)));
final term2 = cos(radians(coordinates.latitude)) * cos(radians(delta2));
final H0 = degrees(acos(term1 / term2));
final m = afterTransit ? m0 + (H0 / 360) : m0 - (H0 / 360);

snippet code (after changing):

final term1 = sin(radians(h0)) -
        (sin(radians(coordinates.latitude)) * sin(radians(delta2)));
final term2 = cos(radians(coordinates.latitude)) * cos(radians(delta2));
var y = term1 / term2;
if(y < -1.0) y = -1.0;
if(y > 1.0) y = 1.0;
final H0 = degrees(acos(y));
final m = afterTransit ? m0 + (H0 / 360) : m0 - (H0 / 360);

the exception is gone and it worked as expected, but i am not sure if the time given is correct or not?

from adhan-dart.

JMApps avatar JMApps commented on June 10, 2024

Have you found a solution? At the moment, the library throws an exception if the latitude is greater than 73 degrees

from adhan-dart.

iamriajul avatar iamriajul commented on June 10, 2024

final term1 = sin(radians(h0)) -
(sin(radians(coordinates.latitude)) * sin(radians(delta2)));
final term2 = cos(radians(coordinates.latitude)) * cos(radians(delta2));
var y = term1 / term2;
if(y < -1.0) y = -1.0;
if(y > 1.0) y = 1.0;
final H0 = degrees(acos(y));
final m = afterTransit ? m0 + (H0 / 360) : m0 - (H0 / 360);

Changes are causing tests to fail!

image

from adhan-dart.

Related Issues (20)

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.