SRL Archive - RS3 Help

Error with official getDensity function?


MysteryMuffin

2014-07-11 23:14:37

I was thinking about implementing similar functionality into my script as Ollybest's getDensity function included in the SRL-6 include, so I took a look at the include and it looks like there may be a small error in the function:

(current function in include)

function TPointArray.getDensity(): extended;
var
tmp: TPointArray;
b: TBox;
begin
tmp := copyTPA(self);

clearDoubleTPA(tmp);
b := getTPABounds(tmp);

result := (extended(length(tmp)) / (((b.x2 - b.x1) + 1) * ((b.x2 - b.x1) + 1)));
end;

Shouldn't the result be:

result := (extended(length(tmp)) / (((b.x2 - b.x1) + 1) * ((b.y2 - b.y1) + 1)));

It looks like an error that would be easy to overlook as the function would likely still appear to work, though the results would be inaccurate if not working with a perfectly square TBox.

Let me know if I'm mistaken.