-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Lemniscate definition #1427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments, maybe to be ignored.
@@ -118,7 +115,7 @@ namespace DGtal | |||
*/ | |||
RealPoint2D getUpperBound() const | |||
{ | |||
return RealPoint2D(myA - myCenter[0] , myB - myCenter[1]); | |||
return RealPoint2D( myA - myCenter[0] , myA*.5 - myCenter[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
myA*.5
-> myA * .5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -109,7 +106,7 @@ namespace DGtal | |||
*/ | |||
RealPoint2D getLowerBound() const | |||
{ | |||
return RealPoint2D(-myA - myCenter[0] , -myB - myCenter[1] ); | |||
return RealPoint2D(-myA - myCenter[0] , -myA*.5 - myCenter[1] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-myA*.5
-> -myA * .5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
else if ( p[1] == 0. && p[0] < 0. ) | ||
angle=3.0*M_PI/2.0; | ||
angle = 3.*M_PI_2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.*M_PI_2
-> 3. * M_PI_2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
const double sint = sin(t); | ||
const double cos2t = pow(cost,2); | ||
RealPoint2D c( myA * sint / (1. + cos2t), | ||
myA * sint * cost / (1. + cos2t) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For t = pi
you will have division by zero, if t
can reach pi
then I suggest make some checks to avoid this to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some tests, a call to this method with PI throws any error bu produce a good result, almost equal to 0.
I'm not sure that this behaviour is common to all environment.
Do you think I should still add a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest handling this situation on your side. If you write a unit test with pi then it will fail due to the fact we now have detection of floating-point arithmetic errors, e.g., division by zero. The value may be correct but I am not sure if this behavior is expected on all platforms.
pow(sin(t),2)*pow(cos(t),2)) / pow(1+pow(cos(t),2),2)); | ||
myA * (cost + 2*sin2t*cost+pow(cost,3)) / pow(1+cos2t,2), | ||
myA * (pow(cost,4) + cos2t - sin2t + | ||
sin2t * cos2t) / pow(1+cos2t,2) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
4 * sint * cost - | ||
6 * sint * pow(cost,3) + | ||
2 * sint * pow(cost,7) ) | ||
/ pow(1+cos2t,4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
…hods with critical values
It looks good to me now. |
I applied same correction than for PR #1426. |
All looks good to me now. |
merging |
PR Description
Change shape definition with only one parameter, as defined by Bernoulli.
Tests of this shape are included in PR #1414
Checklist
cmake
mode (otherwise, Travis C.I. will fail).