Page 1 of 2
Sun Position Calculator
Posted: Thu Apr 17, 2008 9:05 pm
by GNUdo
I'm trying to learn Python programming and recently I saw a discussion about a tool to calc the sun position that can be used with Indigo.
Most of the major 3D programs have a way to set the sun based on location, date, time, etc., but I'm a Blender user and I found no existing solution.
So I decided to write my own script. Initially I thought to expand Blendigo, because I use quite often Indigo to render, but I ended to write a separate script, so that the sun can be managed in Blender like any other lamp.
I think it is simple to understand the various parameters required, but I attached an image showing the script screenshots, including usage instructions.
Do you think it could be useful to someone else than me?
Can someone try it and report back any bug?
I'm sure it is full of bugs, first because I didn't find two different web sites that use the same formulas to do the calculations, but primarly because I'm a bad programmer
Now Fiat Lux!
Update:
# added check to handle wrong sunrise and sunset because of wrong TZ
# the "Now" button sets the current timezone
# added animation support
Posted: Thu Apr 17, 2008 9:07 pm
by Pinko5
Wow GNUdo very useful script i try it asap!!!
Luca.

Posted: Thu Apr 17, 2008 9:26 pm
by Vanessa07
Thx, Many people were waiting for this

Posted: Thu Apr 17, 2008 10:00 pm
by joegiampaoli
Hmmm sun is created below horizon at my location at 3 PM
But looks promising....

Posted: Thu Apr 17, 2008 11:13 pm
by MESCH973
useful script GNUdo grazie
Posted: Fri Apr 18, 2008 12:46 am
by GNUdo
@joegiampaoli:
Do you mean "San Miguel de Allende-MEXICO" (20.92 N, 100.75 W) for your location?
Are you sure you entered all the required data (Latitude, Longitude, Date, Time, Timezone, DST)?
With the data shown in pic1, I get the Sun high on the horizon (see Altitude in pic2).
Posted: Fri Apr 18, 2008 1:12 am
by dougal2
Very cool! I look forward to seeing a blender analemma render
(rendering an analemma is a good way to check that the eccentricity calculation is correct)
Posted: Fri Apr 18, 2008 2:46 am
by Gengibre
Thans, I will try it ASAP
Posted: Fri Apr 18, 2008 3:26 am
by Harry Beaver
This is also very usefull to me, thanks ! trying right now
Posted: Fri Apr 18, 2008 3:50 am
by neepneep
Thanks!!! I've been waiting for a script like this for ages!!
Is it possible to animate ?? (would it be possible to do so with IPO curves?)
Posted: Fri Apr 18, 2008 4:30 am
by Pinko5
Ok for me works fine...
Tnx again
Luca.

Posted: Fri Apr 18, 2008 5:57 am
by GNUdo
@neepneep:
It could be definitely possible to animate, but I'm not so familiar with animations, I've done only the basic tutorials.
Anyway a basic procedure could be:
- in the first frame put the sun here,
- in the next frame put it (here + (time increment)),
- and so on, right?
For animations where frame time increment is 1/25 sec or even 1 sec I don't think it is necessary to vary sun position every frame, maybe every minute..
Ok, I'll look into this
Posted: Fri Apr 18, 2008 7:44 am
by mario
Works fine here:
lat 39°1639 N
long. 8°9135 E
Thanks
Posted: Fri Apr 18, 2008 8:31 pm
by joegiampaoli
GNUdo
Sorry I was enterning the west value wrong it was negative
Working well
Thx

Posted: Fri Apr 18, 2008 9:04 pm
by neepneep
GNUdo wrote:@neepneep:
It could be definitely possible to animate, but I'm not so familiar with animations, I've done only the basic tutorials.
Anyway a basic procedure could be:
- in the first frame put the sun here,
- in the next frame put it (here + (time increment)),
- and so on, right?
For animations where frame time increment is 1/25 sec or even 1 sec I don't think it is necessary to vary sun position every frame, maybe every minute..
Ok, I'll look into this
There may be easier ways to do it - for example you could have an 'Insert IPO keyframe' button on your script GUI and when clicked, it would put the current date/time settings into the IPO editor.
Next, move to the desired end frame, change the date/location/etc in the script and then click 'Insert IPO keyframe'. That would plot the ending date/time and all you have to do is press alt-a to see the sun move - for each frame, the script would check the IPO curve and work out the appropriate interpolated time/date value and update the sun accordingly.
I don't know how useful it would be to animate the location, but naturally animating the time and date would be most useful....