Astroid ore unit count based on radius

stijnster

Active Member
Here is the function to get the amount of units (you still need to multiply that with the ore unit volume) in an astroid, based on the radius. Ofc it only applies if the astroid isn't partially mined yet, but I found that to be very rare.

Code:
public static double CalculateAstroidUnits(double ifRadius)
{
  double tfUnitCount = 0.0;
  // Calculate the unit size based on the radius formula.
  tfUnitCount += (-2.1428304552018226E+03 * Math.Atan(ifRadius));
  tfUnitCount += (2.5003119349589870E+04 * Math.Log(ifRadius));
  tfUnitCount += (2.5013413773803492E+00 * Math.Sin(ifRadius));
  tfUnitCount += (3.8313177601871424E+00 * Math.Cos(ifRadius));
  tfUnitCount += (-1.0906687489673198E+05);
  // Return the amount of units in the astroid.
  return tfUnitCount;
}
 
Last edited:

teabing

Active Member
Code:
function main()
{
	while 1==1
	{
		wait 10
		call CalculateAstroidUnits ${Me.ActiveTarget.Radius}
		echo ${Return}
	}
}



function:float64 CalculateAstroidUnits(float64 ifRadius)
{
	variable float64 tfUnitCount = 0.0
	variable float64 stupidnumber1 = -2.1428304552018226E+03
	variable float64 stupidnumber2 = 2.5003119349589870E+04
	variable float64 stupidnumber3 = 2.5013413773803492E+00
	variable float64 stupidnumber4 = 3.8313177601871424E+00
	variable float64 stupidnumber5 = -1.0906687489673198E+05
	;Calculate the unit size based on the radius formula.
	tfUnitCount:Inc[${Math.Calc64[ ${stupidnumber1} * Math.Atan[${ifRadius}]]}]
	tfUnitCount:Inc[${Math.Calc64[ ${stupidnumber2} * Math.Log[${ifRadius}]]}]
	tfUnitCount:Inc[${Math.Calc64[ ${stupidnumber3} * Math.Sin[${ifRadius}]]}]
	tfUnitCount:Inc[${Math.Calc64[ ${stupidnumber4} * Math.Cos[${ifRadius}]]}]
	tfUnitCount:Inc[${stupidnumber5}]
	; Return the amount of units in the astroid.
	return ${tfUnitCount}
}
This should do the same job
 
Last edited:

Sethric

Active Member
Not like this started working or anything but, should the 2nd part of the math have braces to make the syntax correct?

Code:
	tfUnitCount:Inc[${Math.Calc64[${stupidnumber1} * [B]${[/B]Math.Atan[${ifRadius}][B]}[/B]]}]
instead of

Code:
	tfUnitCount:Inc[${Math.Calc64[${stupidnumber1} * Math.Atan[${ifRadius}]]}]
 

Noob536

Member
this function working in lavishscript if anyone wants it.

Code:
variable float64 PI = 3.1415926535898

function main()
{	
	call CalculateAstroidUnits ${Me.ActiveTarget.Radius}
	echo ${Return}
}

function:float64 rad_to_deg(float64 convertMe)
{
	return ${Math.Calc[${convertMe}*180.0/${PI}]}
}

function:float64 deg_to_rad(float64 convertMe)
{	
	return ${Math.Calc[${convertMe}*${PI}/180.0]}
}

function:int CalculateAstroidUnits(float64 radius)
{
	variable float64 totalOre
	variable float64 degRadius
	
	call rad_to_deg ${radius}
	degRadius:Set[${Return}]
	
	call deg_to_rad ${Math.Atan[${radius}]}
	totalOre:Inc[${Math.Calc[-2142.8304552018226*${Return}]}]
	totalOre:Inc[${Math.Calc[25003.119349589870*${Math.Log[${radius}]}]}]
	totalOre:Inc[${Math.Calc[2.5013413773803492*${Math.Sin[${degRadius}]}]}]
	totalOre:Inc[${Math.Calc[3.8313177601871424*${Math.Cos[${degRadius}]}]}]
	totalOre:Inc[-109066.87489673198]
	return ${totalOre.Int}
}
 
Top Bottom