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

Angle calculation resulting in strange behavior
Shift angle orientation using atan2
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

Categories

HOME
fabricjs
api
spark-streaming
forms
jsf-2.2
cq5
limit
azure-container-service
frontend
odoo-8
performancepoint
openstreetmap
drop-down-menu
watson-conversation
cmdb
http-post
mvc-mini-profiler
production
bourbon
gmm
href
string-concatenation
froala
tiki-wiki
winexe
corenlp-server
left-join
card.io
twos-complement
pdw-file-browser
imx6
parse-tree
filesystemwatcher
opensmpp
parser-generator
microsoft-metro
lpsolve
ssrs-2014
congestion-control
apollostack
knime
httr
mschart
tf
manova
bluez
x-ray
trojan
static-cast
flyout
cmp
jtree
rxtx
branch-prediction
gets
redistributable
actor-platform
async.js
cifilter
cortex-m
fink
nupic
exim4
rewrite
forwarding
microsoft-reporting
ess
dock
coda
omnifaces
jquery-forms-plugin
adehabitathr
nodelist
post-commit-hook
sql-scripts
machine-instruction
genymotion-call
rmysql
with-statement
memset
android-framework
mt4j
sphinxql
mysql-error-1044
c++builder-xe5
beaker-testing
mvc-editor-templates
pclzip
cardreader
virtual-pc
extreme-programming
sentestingkit
apache-whirr
google-maps-mobile
convention
mysql-error-1205
socketserver
uideviceorientation
delimited-text
facebook-iframe
isapi-extension
glui
purepdf
wcf-instancing
linfu-dynamicproxy
commercial-application

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