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

duplicated code in TheoryInterferenceOverlay #276

Closed
pixelzoom opened this issue Dec 19, 2018 · 3 comments
Closed

duplicated code in TheoryInterferenceOverlay #276

pixelzoom opened this issue Dec 19, 2018 · 3 comments

Comments

@pixelzoom
Copy link
Contributor

For code review #259, identified by grunt find-duplicates:

This code is duplicated in 2 places in TheoryInterferenceOverlay. Lines 63-79 and 86-101.

                  const separation = scene.slitSeparationProperty.value;
                  const arg = ( m + addition ) * scene.wavelength / separation;

                  if ( arg <= 1 ) {
                    const theta = sign * Math.asin( arg );

                    const x = LENGTH * Math.cos( theta );
                    const y = LENGTH * Math.sin( theta );
                    const line = new Line( barrierX, barrierY, barrierX + x, barrierY + y, {
                      stroke: type === 'maxima' ? MAXIMUM_COLOR : MINIMUM_COLOR,
                      lineWidth: LINE_WIDTH
                    } );
                    this.addChild( line );
                  }
@samreid
Copy link
Member

samreid commented Dec 21, 2018

Here's a visual diff:

image

The duplicated part is isolated to the if statement.

samreid added a commit that referenced this issue Dec 21, 2018
@samreid
Copy link
Member

samreid commented Dec 21, 2018

Factored out in preceding commit, please review.

@pixelzoom
Copy link
Contributor Author

👍 Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants