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
Sympy cancelling terms in the Jacobian of polar coordinates transformation
Distance formula between two Lat/Longs Autoit?
Trigonometric Functions in Pseudo Code
Inverse-Kinematics: How to calculate angles for servos of a robotic arm to reach all possible points in a canvas?
How to calculate Heading using Gyro and magnetometer
Integral of a sign function proof
Best way working with trigonometric functions
Calculate place of point C to be equal distance away from points A and B
How to compute sum of angles from sine and cossine?
Counting trig ops as measure() function to fu() in sympy
Find a coordinate along a path
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