Can someone explain to me what these line is doing?
Quote:
m_humanProx = fixed(3,1) / isqrt(9 + 10*(m_path.sectorX*m_path.sectorX + m_path.sectorY*m_path.sectorY + m_path.sectorZ*m_path.sectorZ));
I see a distance calculation, that is then mul'd by 10 and the result has 9 added, before we find the square root... so that looks a bit like a distance calculation with some kind of scaling???Then we divide by fixed(3,1) which appears to be another arbitrary huge value in integer terms but the divide might not be doing a straight integer div, in fact I think it's doing it in fixed terms.
How does this calculation work?
-
fluffyfreak
- Private
- Posts: 1292
- Joined: Sun Nov 27, 2016 12:55 pm
RE: How does this calculation work?
Some more of Brianetta's fearfully crazy math, maybe? 
RE: How does this calculation work?
Hey,It looks to be: 3 / sqrt(9+10 *(x^2+y^2+z^2))so for sector 1,1,1:3/ (isqrt(9+10*(1+1+1)) = 3/isqrt(39) = 3/6 = fixed(1,2) or 0.5So... that gives a number from 1.0 down to something really small depending on how far away you are from Earth.the 9 is so that sector 0,0,0 provides a 1.0 value for human proximity. Sqrt of 9 is.. :)Unless I'm mistaken the use of fixed() is to ensure different platforms always arrive at the same result, its used a lot in galaxy generation to ensure each system is identical on every platform.
-
fluffyfreak
- Private
- Posts: 1292
- Joined: Sun Nov 27, 2016 12:55 pm
RE: How does this calculation work?
Cheers dan :)my hangover maths isn't what it used to be!
RE: How does this calculation work?
UncleBob wrote:
Some more of Brianetta's fearfully crazy math, maybe?
It's actually related (-:
RE: How does this calculation work?
fluffyfreak wrote:
Cheers dan :)my hangover maths isn't what it used to be!
hehe, yw
Quote:
Some more of Brianetta's fearfully crazy math, maybe?
Tomm's, he wrote the 3d galaxy.
RE: How does this calculation work?
s2odan wrote:
Quote:
Some more of Brianetta's fearfully crazy math, maybe?
Tomm's, he wrote the 3d galaxy.
Actually that's ancient sysgen code, but Tomm did write that too