int FindY(CalibrationPoint cp1, CalibrationPoint cp2, int x) { //y = ax + b //b = y - (ax) float a = (cp2.WebcamY - cp1.WebcamY) / (cp2.WebcamX - cp1.WebcamX); float b = cp1.WebcamY - a * cp1.WebcamX; return (int)(a * x + b); }
int FindX(CalibrationPoint cp1, CalibrationPoint cp2, int y) { //y = ax + b //b = y - (ax) //x = (y - b) / a float a = (cp2.WebcamY - cp1.WebcamY) / (cp2.WebcamX - cp1.WebcamX); float b = cp1.WebcamY - a * cp1.WebcamX; return (int)((y - b) / a); }