trigonometry


Trigonometry & Sunset


Not sure whether this question is appropriate on this forum, but very sure there is someone who can answer this.
Reason I'm asking this, is that I failed to pay attention in school to anything dealing with sines and cosine stuff, and somehow I think this is the direction I have to look for.
So, I'm making this little clock app, in which I want to set the background color to more or less correspond with the amount of sunlight at a given time. It doesn't need to be highly accurate, so, I don't need the real time sun position. The simple reasoning is: At midnight, it is supposedly the darkest hour (black background, 0% white), and at noon, the sun is shining the brightest (white background, 100% white), and everything in between should set the background in an appropriate grey tint.
Input to the algorithm is just the hour, ranging from 0 to 24.
Thanks in advance.
PS, I'm writing the app in Objective-C, but I think the equation will be so simple, that that would be irrelevant.
I guess this is the wrong place for this question (as you as for mathematics, instead of programming).
But anyway, this is what you can do (as you seem to wish to work with a sine/cosine):
Do the hour *7,5
So 0->0, 12->90, 24->180
As the sin(0)=0, sine(90)=1 and sine(180) = 0, (values 0,90,180 are degrees, not radians). You will get a value ranging from 0-1 with a max at 12 o'clock and a minimum at 0h and 24h.
I do not know Objective-C, but i guess it will look something like this:
hourdegrees = 7.5 * Input(hour);
hourradians = M_PI * hourdegrees / 180;
density = sin(hour);
M_PI is the call-function for Pi(3.14...) in Objective C
Converting degrees to radians: know that 360degrees = 2*Pi radians (see here: Sine to radians Objective-C)
Hope you are something with this

Related Links

estimate angle between two lines y = 1000x and y = 999x
Need help revising a simple formula to make it universal
SWIFT trig functions
Simplifying atan(tan(a+b))
2 Different Radians constant calcuations whats the difference?
Trigonometry & Sunset
Calculating collisions with Radians incrementing
How do arbitrary-precision libraries like mpmath evaluate simple trigonometric functions?
How can I calculate the angle
Finding Shortest Distance Between Two Parallel Lines, With Arbitrary Point [closed]
how to convert depth in Z-cordinate
How can I simplify this expression with trigonometric in Maple?
Require trigonometry assistance with ship/wave movement
Trigonometry - Find where two curves intersect
How to calculate point 'along' unit circle radian [closed]
Issues with bullet entry points for “shoulder mounted” guns

Categories

HOME
azure-stream-analytics
ggplot2
nvd3.js
saml-2.0
devise
hpc
jquery-ui
special-characters
jquery-ui-sortable
project-intu
atlassian
microsoft-dynamics-nav
articulate-storyline
spring-async
joptionpane
php-mysqlidb
mongoid6
direct3d11
underscore.js
8051
quantlib
iis-express
kodi
fstream
android-maps-extensions
nested-lists
python-import
modalviewcontroller
yowsup
openproject
watchman
sessionstorage
tex
node-mssql
hackintosh
azure-arm
odoo-website
chronicle-map
xmldocument
oim
semantic-logging
appdomain
yii2-user
headless
quicktime
css-transforms
janus
d3-force-directed
pybrain
mapxtreme
scaffolding
swizzling
stream-processing
ikiwiki
pushbots
relativelayout
assertion
ess
flock
poppler
pax-exam
teamcity-9.1
snackbar
zxspectrum
cakephp-2.7
pseudo-class
deform
easyrtc
create.js
jjaql
rfc5322
oocss
rolify
diem
composite-component
insert-id
apache-abdera
josql
apache-whirr
fitbounds
filemerge
cgbitmapcontextcreate
metaweblog
squishit
google-wave
interop-domino
sqlobject
wcf-proxy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App