riwu
2012-10-31 07:17:42
The current MiddleTPA function returns the mean of the TPA. This is often not useful in RS where you want to ensure that the point retrieved lies on the object you are finding.
Eg.

If you get the TPA of the orange color of the copper ore, then splitting it by a distance such that veins from the same ore will be group together, it may result in the adjacent ore being grouped together as well. The resulting point from MiddleTPA could then lie in between the 2 ores, resulting in an unsuccessful click (due to clicking in between the ores).
A more reliable approach could be to get the median of the TPA. The difference between mean and median is that the formal is just a numerical average of the data while the latter is a point that is actually present in the data.
Eg. given an array of Integers: [1, 9, 10, 2, 11], the mean is 6.6, while the median is 9, the middle index in the array (after sorting it by size).
Hence I thought of an alternative function that gets the median of TPA, and since it is a point where the color is found, it will always be a point on the object (and not between 2 obj etc).
Would this function be more reliable than MiddleTPA for finding object in RS? And how can it be improved etc? Discuss!
Also can someone explain what a functional pointer is for? Why do we make srl_GaussRand a functional pointer, instead of just calling GaussMarsPolar, or using a wrapper?
Eg.
If you get the TPA of the orange color of the copper ore, then splitting it by a distance such that veins from the same ore will be group together, it may result in the adjacent ore being grouped together as well. The resulting point from MiddleTPA could then lie in between the 2 ores, resulting in an unsuccessful click (due to clicking in between the ores).
A more reliable approach could be to get the median of the TPA. The difference between mean and median is that the formal is just a numerical average of the data while the latter is a point that is actually present in the data.
Eg. given an array of Integers: [1, 9, 10, 2, 11], the mean is 6.6, while the median is 9, the middle index in the array (after sorting it by size).
Hence I thought of an alternative function that gets the median of TPA, and since it is a point where the color is found, it will always be a point on the object (and not between 2 obj etc).
function MedianTPA(TPA: TPointArray): TPoint;
begin
if Length(TPA) < 0 then
Exit;
SortTPAFrom(TPA, Point(0,0));
srl_GaussDev_Range:= 0.1;
Result:= TPA[iGaussRange(0, High(TPA))];
srl_GaussDev_Range:= 0.3;
end; This would give a random point in the TPA, of which the tendency to choose the points near the middle being much higher. Similar to a normal distribution but with lower deviation. Would this function be more reliable than MiddleTPA for finding object in RS? And how can it be improved etc? Discuss!
Also can someone explain what a functional pointer is for? Why do we make srl_GaussRand a functional pointer, instead of just calling GaussMarsPolar, or using a wrapper?