My application should evaluate the length (in millimeters) of an object using euro coins as a reference. This is an example screenshot:
To get the diameter of the photographed coin, I first calculated the equation of a circle passing through these 3 points of the form
x^2 + y^2 + ax + by + c = 0
and then I have a diameter on
2 * square_root((a/2)^2 + (b/2)^2 -c)
.
Finally, I can do the following proportion to get the length of the red pen:
let distanceGreen:Double = Double(sqrt(pow(self.greenLocationA.center.x - self.greenLocationB.center.x, 2.0) + pow(self.greenLocationA.center.y - self.greenLocationB.center.y, 2.0))) let estimatedMeasure:Double = (distanceGreen * Double(ChosenMeter.moneyDiameter)) / diameter
where in ChosenMeter.moneyDiameter
the actual diameter of the selected coin is stored as a link (by clicking one of the 3 buttons below).
I need to work with Double
instead of CGFloat
, because this tutorial for working with a system of linear equations (to get, b, c coefficient of a circular equation) works with Double.
The problem , the estimated length of the red pen is always overestimated more than 10 mm. I think I should apply a correction factor or complicate the calculation taking into account other factors, but what? Can you give me some advice? Any help would be helpful to me.
source share