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

are Mass initialDisplacementProperty and initialVelocityProperty necessary? #44

Closed
pixelzoom opened this issue Feb 10, 2020 · 1 comment

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Feb 10, 2020

Related to #2 (code review).

In Mass.js:

      // @public {Property.<Vector2>} mass current displacement (from the equilibrium position)
      this.displacementProperty = new Vector2Property( new Vector2( 0, 0 ), {
        tandem: tandem.createTandem( 'displacementProperty' )
      } );

      // @public {Property.<Vector2>} mass initial displacement
      this.initialDisplacementProperty = new Vector2Property( new Vector2( 0, 0 ), {
        tandem: tandem.createTandem( 'initialDisplacementProperty' )
      } );

      // @public {Property.<Vector2>} mass current velocity
      this.velocityProperty = new Vector2Property( new Vector2( 0, 0 ), {
        tandem: tandem.createTandem( 'velocityProperty' )
      } );

      // @public {Property.<Vector2>} mass initial velocity
      this.initialVelocityProperty = new Vector2Property( new Vector2( 0, 0 ), {
        tandem: tandem.createTandem( 'initialVelocityProperty' )
      } );

Every Property stores it's initial value, and the initial value can be restored by calling reset. So I wonder if this.initialDisplacementProperty and this.initialVelocityProperty are really necessary.

On the other hand, I see initialDisplacementProperty.set and this.initialVelocityProperty called, but don't understand why:

// OneDimensionModel.js
this.masses[ i ].initialDisplacementProperty.set( this.masses[ i ].displacementProperty.get() );
this.masses[ i ].initialVelocityProperty.set( this.masses[ i ].velocityProperty.get() );

// TwoDimensionsModel.js
this.masses[ i ][ j ].initialDisplacementProperty.set( this.masses[ i ][ j ].displacementProperty.get() );
this.masses[ i ][ j ].initialVelocityProperty.set( this.masses[ i ][ j ].velocityProperty.get() );

Recommended to:

  • Verify that initialDisplacementProperty and initialVelocityProperty are really needed.
  • If they are needed, document why. If not, remove them.
@tmildemberger
Copy link
Contributor

They were indeed not needed. Thanks for pointing it out. 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