How does this calculation work?
Posted: Sun Nov 13, 2011 1:47 pm
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.
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.