A New Start... Geoff's Handbooks
by
, 09-03-2015 at 04:04 PM (11495 Views)
Not to long ago there was a request in the forums for a cookbook written by one Geoff. The problem was... The site that hosted the document was no longer active and therefore removed from the interwebs. Remembering the Internet Archive, having need of it for a Blender tutorial I did many years ago, I started the hunt for Geoff's Climate Cookbook and found a copy of it. While starting to read Geoff's Cookbook, I found a link that lead to another, severely detailed, page on Creating an Earthlike Planet. Following that trail into the rabbit hole I go!
---- Disclaimer : I know not what I am doing, and ramble ----
So the handbooks as I call them. I have them on a server deep underground in a nuke hardened bunker and you need top notch credentials to get to them... No? Ok.. here they are:
The one that started it all... Geoff's Climate Cookbook
The one that I am current lost in.... Creating an Earthlike Planet
Once I figure out getting these onto this site I will do so, and will also move them to my Drive so that when my server goes down they are not lost again.
Sooooo... onwards into the depth of my insanity with math and world generation.... Well.. Math at least...
Going through the Creating an Earthlike Planet document, I quickly see the lengths, and reasons, for Geoff's lengthy discussion and guidance. While I would like to be called a writer, I am merely novice compared to others and just like to daydream about strange worlds and what they look like. However, Geoff *is* a writer and has decided to do what other writers should do as well. Not only develop a believable world, but one that makes the reality check of what we know a world looks like in the real world. To do this, Geoff sets off into not only the creation of a believable world, but one that has a galaxy in it that can be seen from the planet as well.
While the astronomy angle is intriguing, it is not one that is absolutely necessary. However... I actually like the thought of generating a star map that the denizens of a planet will see when they look up into the night sky and the neat thing is... It allows you to really create your own constellations based upon the random dots that appear.
The difficulty is not that the math is there. It is not that the math is even all that difficult. The problem is that the visualization of the math is not always easy to achieve, or the knowledge of what to use to generate it is not always known. Fortunately, I am quirky enough to want to dive in and stretch my math mind more as I get older, and know several methods to generate visual representations. The method that I am going to be using throughout this blog is by using a mathematical software package that is called GNU Octave. It is a free alternative to the more widely known Matlab, but having a price tag of free makes Octave more desirable! I am more than happy to lend help if anyone is going to try using what I put here, but I will not delve too far into how to use Octave outside of what I am doing. That will make these blog posts WAY too long, and there is better information on using Octave than me.
Begining of the Stars!
On the third page of the Creating an Earthlike Planet {forevermore referred to as CEP.pdf}, Geoff starts into his Astronomy topic. It is not until page 4, as the PDF version has it at least, that the first math formula appears. The equations shown, mag.i = 2 * log.10 i + B - R * rand(100) / i, is for the magitude of the i'th brightest star. This is as seen from planet side. While this is useful, it generates a single data point if done by hand. The obvious step is to crunch a range of numbers through the formula and record those values. This is where Octave comes in.
The initial steps that I took were to first go through and generate the data as it was presented, then I decided to make a function that would allow me to put the variables in and run it in one go. Since this is my blog, I am going to go step by step on this one since it is rather simple, but the longer ones will just have the final function put in code brackets.
Since there are only three variables needed for the magnitude function, I set it up as the following:
i : I changed this to x for ease of graphing in my mind. i is typically reserved for loops in programming and once this is put into a function... loops will follow. In octave this will be done over a range from 1 to 100 to keep things simple. So in octave it is put in as: x = 1:1:100;
B : I left this as B, and set it as: B = -1;
R : Again I left this variable alone and set it as: R = 0.01;
The formula was then entered as: mag_i = 2 * log10(x) + B - R * rand(1,100) / x;
Now.. for those following, nothing appears to happen. This is due to using the semicolons at the end of the variable declarations. This silences the creation report that follows the declaration of the variable. For most it is fine to leave off the ; however keep in mind that doing this in an automated function can cause the function to stop running at times.
Figure 1: The Results of all Variable Entry
So now that the variables have been declared, and the first dataset/matrix has been generated... Well.. let's make sure that the data is really there... This is done by entering in the matrix name, in this case mag_i...
Figure 2: What is Stored in mag_i
Good. It *does* have data, but it does not do much good as it is as that is meaningless without a location that they exist in... Location... hrmm... that should be simple...
Where do the stars belong?
Geoff states that for the right ascension anything random is acceptable, yet the declination should follow a structured formula. This gave me a bit of issue in octave, as the function that can generate between two values... It returns an integer instead of a decimal. I ended up with three bands of stars instead of a central band and then disbursement. I was able to solve this though by using the randi([a,b]) function multiplied by the rand(a) function. rand(a) will spit out a decimal matrix of size 'a' between 0 and 1. randi([a,b]) will give an integer from the range of a to b. The problem is... How to get a range of random values from different sets of data into a matrix... I settled on the first for loop that I will eventually have in a finished function.
for i=1:1:100
location(i,1)=randi([-100,100]);
end
This simple loop makes a new matrix called location and sets the first column of size i with the random values from -100 to 100.
For the declination, Geoff suggests doing an inverse cosine of the random value from -1 to 1. This is where the double random functions above come into play, again another for loop as well....
for i=1:1:100
location(i,2)=acos(randi([-1,1]) * rand(1));
end
There are better ways to create this random value, something like A + (B - A) * rand(1) would work but only if B did not equal A nor -A, but what I have works so meh. Below are the loops, and I entered location followed by enter to display the values stored.
Figure 3: Partial Printout of the Matrix 'location'
From here I split the matrix into two for X and Y locations. This is doable in one step, simply make the matrix into the value... It was really late when I did this so I have what I have and it works
y = location(i,2);
x = location(i,1);
Time to SEE!
Now the only thing left to do is plot the results! The best way to do this is through the use of a scatter plot. In octave it is done using scatter() and adding a few values passed through to get all of the data needed.
scatter(x,y,magi,magi,'filled');
This will display your magi data at the location (x,y). It reads it linearly, so the first line of magi is set to the first line of location, which was split into x and y for plotting purposes. The result is:
Figure 4: Finished plot
This looks like it is on the right track, but rather sparse to me. I will correct that after I have created the function. The function will essentially be all of the steps listed above, but in one shot to allow easier use and not have to type everything every time that I want to create a starmap. There are other uses for starmaps other than for world creation... but that is a different site. For now, here is the function as I have it in octave.
Now I can go back and address the sparse look of the starmap.... let's try 800 points of data this time....Code:function [magnit] = starmap(initval,endval,magval,randval,lowerb,upperb) B=magval;R=randval;ndx=initval:1:endval;magi=2*log10(ndx)+B-R*rand(1,endval)/ndx; for i=initval:1:endval locx(i,1)=randi([lowerb,upperb]); locy(i,1)=randi([lowerb,upperb]); %locy(i,1)=acos(randi([-1,1])*rand(1)); % Creates a band at 1.5 yuk end scatter(locx,locy,magi,magi,'filled'); endfunction
starmap(1,800,-1,0.01,-800,800)
Which produces:
Figure 5: My Finished Starmap
Next Installment
From here, the next step is to continue through the document and write up the next section, The sun. I am sure more math will be forthcoming, but I think for now it is time for a rest...