Note: Hopefully this is accurate, but I don't remember if I made further changes. (SL)

Note: This document doesn't mention eclipses, and doesn't mention how substellar (planet) objects and companion stars transmit heat, but suffice it to say that companion stars act like S08s and substellar (planet) objects act like S05s.

These temperatures are all celsius.

(Old temperatures)
Mass of star:
	tmp_float = 1e-3 * qt_M_PI * ap_target_ray * ap_target_ray * ap_target_ray;
	tmp_float *= starmass_correction[ap_target_class];
	if (nearstar_class == 8 || nearstar_class == 9) {
		fast_srand ((long)ap_target_x%32000);
		switch (fast_random(5)) {
			case 0: tmp_float /= 1 + 5 * fast_flandom(); break;
			case 1: tmp_float /= 1 + fast_flandom(); break;
			case 2: tmp_float *= 1 + fast_flandom(); break;
			case 3: tmp_float *= 1 + 20 * fast_flandom(); break;
			case 4: tmp_float *= 1 + 50 * fast_flandom();
		}
	}
	
Surface temp:
	Start with mass of star (tmp_float)
	tmp_float /= 0.38e-4 * ap_target_ray;
	if (ap_target_class == 6) tmp_float *= 0.0022;

External environment temp:
	fast_srand (secs/2);
	tmp_float = 16 - dsd * 0.044;
	tmp_float *= fabs(tmp_float);
	tmp_float -= (tmp_float + 273.15) * eclipse;
	if (tmp_float < -269) tmp_float = fast_flandom() - 269;

((16-dsd*.044)*fabs(16-dsd*.044)) - eclipse factor

External environment radiation level:
	tmp_float = 50 + random (10) - random (10);
	tmp_float *= (1 - eclipse);
	tmp_float *= 100 / dsd;
	if (nearstar_class == 11) {
		if (gl_start < 90)
			tmp_float *= 75 + random (50);
		else
			tmp_float *= 50;
	}
	if (nearstar_class == 10) tmp_float *= 0.25;
	if (nearstar_class == 9) tmp_float *= 3;
	if (nearstar_class == 8) tmp_float *= 1.5;
	if (nearstar_class == 7) tmp_float *= 25;
	if (nearstar_class == 6) tmp_float *= 0.01;
	if (nearstar_class == 5) tmp_float *= 0.1;
	if (nearstar_class == 4) tmp_float *= 10;
	if (nearstar_class == 3) tmp_float *= 0.5;
	if (nearstar_class == 2) tmp_float *= 18;
	if (nearstar_class == 1) tmp_float *= 5;
	srand (secs);
	tmp_float *= 1
		   + (float)(random(100)) * 0.001
		   - (float)(random(100)) * 0.001;

On the roof:
	fast_srand (secs/2);
	pp_temp = 90 - dsd * 0.33;
	pp_temp -= 44;
	pp_temp *= fabs(pp_temp * 0.44);
	pp_temp -= (pp_temp + 273.15) * eclipse;
	if (pp_temp < -269) pp_temp = fast_flandom() - 269;

((46-dsd*.33)*fabs((46-dsd*.33)*.44) - eclipse factor

On a planet:
	pp_temp = 90 - dsd1 * 0.33;
	
	And then lots of adjustments for atmosphere, exposure levels (in nighttime etc), etc.

New surface temp:
	(mass * class_surfacetemp_mult[class]) + class_surfacetemp_add[class]

Note:
We defined one dyam as 70,000,000 meters. However, the formulas don't need to convert from dyams to meters, since the conversion factor just cancels out anyways.

Unified temperatures:
	We have:
		radius = "ray".
		StefanBoltzmanConstant = 5.67 W/m^2 IIRC
		SurfaceTempK = SurfaceTemp + 273.15
		SurfaceArea = 4*PI*ray*ray
		#define StefanBoltzmanConstant 5.67
		#define WattsPerMeterSquaredToKelvin 8.3090779424284298814520715488599e-11 (This was calculated, how is described later)
			
	Luminosity=StefanBoltzmanConstant*SurfaceArea*SurfaceTempK*SurfaceTempK*SurfaceTempK*SurfaceTempK
	Brightness=Luminosity/(4*PI*Distance*Distance)
		The 4PI in Brightness cancels out one in Luminosity.
	
	ray for bal is 5.021. In meters: 351,470,000. Sol's radius is 296,000,000 meters.
	
	Thus Brightness=(StefanBoltzmanConstant*ray*ray*SurfaceTempK*SurfaceTempK*SurfaceTempK*SurfaceTempK)/(Distance*Distance)
	For bal Brightness=(5.67*351470000*351470000*5214.15*5214.15*5214.15*5214.15)/(15,260,000,000*15,260,000,000) = 2,223,231,040,555.27 watts per meter squared //NOT 280,000,000,000*280,000,000,000) = 6,603,551,998.21 watts per meter squared
	TempK = WattsPerMeterSquaredToKelvin * Brightness
	If we want TempK for Felysia to be 275K, then:
		WPMSTK = 275K / 2,223,231,040,555.27 = 1.2369384692079349414817948768129e-10
	If we want it to be 184.73:
		WPMSTK = 184.73 / 2,223,231,040,555.27 = 8.3090779424284298814520715488599e-11
	
	* (Measured temperature there now is ~ 281 K, so our numbers aren't exactly right, but this is a good temperature)
	
New Planet Temperatures:
	They have a bunch of modifiers.