We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 33dc4a7 commit c2172a2Copy full SHA for c2172a2
apriltag_quad_thresh.c
@@ -976,7 +976,12 @@ int fit_quad(
976
double dy1 = quad->p[i1][1] - quad->p[i0][1];
977
double dx2 = quad->p[i2][0] - quad->p[i1][0];
978
double dy2 = quad->p[i2][1] - quad->p[i1][1];
979
- double cos_dtheta = (dx1*dx2 + dy1*dy2)/sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2));
+ double denominator = sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2));
980
+ if (denominator == 0) {
981
+ res = 0;
982
+ goto finish;
983
+ }
984
+ double cos_dtheta = (dx1*dx2 + dy1*dy2) / denominator;
985
986
if ((cos_dtheta > td->qtp.cos_critical_rad || cos_dtheta < -td->qtp.cos_critical_rad) || dx1*dy2 < dy1*dx2) {
987
res = 0;
0 commit comments