Trigonometric functions (sin, cos, tan)


#1

Do these exist in WebCore?
Can anyone point me to the docs for them?

Thanks,

James


#2

They don’t exist as functions today. Not that hard to add.

Is this for ST or HE?


#3

Sorry, just being curious. What do you need trig functions for?


#4

image :slight_smile:


#5

This is for ST.
I have external solar blinds - I want to work out when to open & close them, which depends on the position of the sun, but is not a fixed offset from sunrise or sunset. I may be able to do it by converting sunset etc in to a number of minutes then scaling it…


#6

I originally posted this in the ST forums, but I guess I should post it here as well:


No need to recreate the wheel… I have crafted a piston that takes this concept to another level… It accurately estimates how many degrees the sun is above the horizon at any given moment… (which can easily be incorporated into a piston that auto-closes blinds before the glare happens)

The math changes based on latitude, and changes every day due to the seasons. And of course, the height of the sun changes at every moment throughout the day, but my formula works year-round(with 99% accuracy during all of the important times of the day)

I have not shared this ‘astronomical’ formula publicly… mostly because of how much work it took to get all 57 unique math formulas to work hand-in-hand. (but it has been tested for well over a year, in many various locations around the globe)

Honestly, it is the only solar altitude estimator I have ever seen anywhere!
(my goal was to make it 100% self-contained, without using any external APIs)

I also use this method to determine when to turn on my porch lights.
(no longer basing it on sunset times, but when the sun drops below 8° from the horizon)

Feel free to send me a PM if you are interested in this technological wonder, LOL.


Note, this is for advanced users who want a truly 'Smart" home…:

There are only a dozen households in the world that are using my code here, so due to the complexity and uniqueness of this, I will only share this beauty when “on-the-clock”…

I hope you can understand.


Edit for clarification:

My formulas were designed for those of us who live between latitude 24.0 and 65.6.

Those who live near the poles, will have days with no sunlight, and days with no darkness…
Those who live near the equator, will have days where the sun is to the north, and days where it’s to the south.

My formulas do not take this into account.

Thankfully, most of us live in the highlighted regions above, where the formulas work very well.

Let me know if you are interested… It is a real work of art.

Here is a little Legend to whet your appetite:

pic

(the pic was taken shortly before noon)

  • When the sun sets, the dial continues to move below the horizon
    (I added additional code to make the dial fluid)

Edit: The yellow bar will grow (or shrink) a bit each day to align with the angle of the sun at mid-day.
IE: On the day this pic was taken, the sun only climbed halfway up into the sky. (44°)


Outdoor luminance/lux without Nest Weather
#7

For a visual, I took the time to convert the results of the formula into a nice gauge.
The needle here literally shows how high is the sun above the horizon.

In this example:

  • I took screenshots every ten minutes throughout the day.
  • The current altitude (and max for the day) is on the bottom line…
  • The sun will be 40.71° above the horizon at high-noon.
    (shown by the edges of the yellow bar)
  • The eastern horizon is next to R for sunrise
  • The western horizon is next to S for sunset
  • The needle shows how many degrees is the sun over the horizon
    (with the exception at high noon - see note below)

4c27461c56a0277cbba0ab58f66582158bd5792d

Note: During the hour of high noon, the altitude only changes a half a degree, so I have the needle static during that hour.


Of course, the gauge is entirely optional. Many clients only want the degrees pushed to a @global so other pistons can reference that number.


Note:

The animated image above only shows sunrise to sunset, but the needle actually moves 24 hours a day.
(moving ‘below’ the horizon throughout the night)


#8

I have always suspected that you are a mental giant. This just proves it :smile:


#9

Thank you for the compliment. I would probably be embarrassed if I told you just how many hours I sunk into this monstrosity.

Out of the 57+ formulas I used, only 3 of them may be familiar to astronomers…
The other 54+ formulas are creations of mine.


For reference, here is a more detailed Legend, showing samples & accuracy levels for the various output:

{altNow} is the one that denotes the altitude.


#10

That does look v impressive!
I think however, it’s over complicating things for me - as you say, it’s for really complex setups.
If I open the blinds 10 mins late some of the time it really doesn’t matter.
Additionally I have the added complication of over-hangs above the windows, so I were to try and do it exactly I’d have a weird combination of azimuth and elevation to consider.

Best,

James


#11

True. The piston is quite complex… but for the end-user, it simply creates a decimal that represents the altitude of the sun.

All of the other variables in that list are things that I had to calculate in order to determine the sun’s elevation at any given moment.


As far as the overhangs go, it simply means that each blind can use a different threshold to shut the blinds.

IE:
Living room closes at 10°
Bedroom closes at 8°
etc.


Despite the needle moving in a circle, my piston does not measure the cardinal direction (or azimuth).
… but instead measures the altitude of the sun (degrees above the horizon).

(I corrected my earlier post)