Sun Position Calculator
Sun Position Calculator
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
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
- Attachments
-
- fiat_lux.zip
- Fiat Lux v0.7
- (6 KiB) Downloaded 417 times
-
- Fiat Lux screeshots (old version)
- fiat_lux.gif (86.9 KiB) Viewed 6668 times
Last edited by GNUdo on Sat Apr 19, 2008 4:40 am, edited 1 time in total.
- joegiampaoli
- Posts: 837
- Joined: Thu Oct 05, 2006 7:12 am
- Location: San Miguel de Allende-MEXICO
- Contact:
@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).
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).
- Attachments
-
- pic1.gif (28.92 KiB) Viewed 6552 times
-
- pic2.gif (23.71 KiB) Viewed 6554 times
-
- Posts: 34
- Joined: Thu Dec 06, 2007 11:52 pm
@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
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
- joegiampaoli
- Posts: 837
- Joined: Thu Oct 05, 2006 7:12 am
- Location: San Miguel de Allende-MEXICO
- Contact:
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.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
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....
Who is online
Users browsing this forum: No registered users and 32 guests