Skip to content
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

Merged
merged 7 commits into from
Jul 26, 2019
Merged

Conversation

akrah
Copy link
Contributor

@akrah akrah commented Jul 10, 2019

PR Description

Change shape definition with only one parameter, as defined by Bernoulli.
Tests of this shape are included in PR #1414

Checklist

  • Unit-test of your feature with Catch.
  • Doxygen documentation of the code completed (classes, methods, types, members...)
  • Documentation module page added or updated.
  • New entry in the ChangeLog.md added.
  • No warning raised in Debug cmake mode (otherwise, Travis C.I. will fail).
  • All continuous integration tests pass (Travis & appveyor)

Copy link
Member

@copyme copyme left a 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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

myA*.5 -> myA * .5

Copy link
Contributor Author

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] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-myA*.5 -> -myA * .5

Copy link
Contributor Author

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;
Copy link
Member

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

Copy link
Contributor Author

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) );
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@copyme
Copy link
Member

copyme commented Jul 18, 2019

It looks good to me now.

@akrah
Copy link
Contributor Author

akrah commented Jul 18, 2019

I applied same correction than for PR #1426.

@akrah
Copy link
Contributor Author

akrah commented Jul 19, 2019

All looks good to me now.

@dcoeurjo
Copy link
Member

thanks @akrah and @copyme !

@dcoeurjo
Copy link
Member

merging

@dcoeurjo dcoeurjo merged commit 93c4820 into DGtal-team:master Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants