phetsims / projectile-data-lab

"Projectile Data Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 0 forks source link

[CODAP] Angle Stability using negative numbers #356

Open Matthew-Moore240 opened 1 month ago

Matthew-Moore240 commented 1 month ago

Test device Win 11 Desktop

Operating System Win 11 23H2

Browser Firefox 131.0.3

Problem description From https://github.com/phetsims/qa/issues/1157 Angle Stability goes into the negative.

Steps to reproduce N/A

Visuals image

KatieWoe commented 1 month ago

Noting that the more stable, the more negative the number, which seems to be oposite the intended behavior.

samreid commented 3 weeks ago

In this code, we actually get the value of launcherStandardDeviationAngle and, after a linear transform, rename it to angle stability.

        const launcherMechanism = launcherName === 'custom' ? launcherMechanismName : '?';
        const angleStabilitySliderValue = ( 5 - 0.2 ) / ( 5 - 0.2 ) * ( projectile.launcherStandardDeviationAngle - 5 ) + 0.2;
        const angleStabilityRounded = valueRoundedToThousandths( angleStabilitySliderValue );
        const angleStability = launcherName === 'custom' ? angleStabilityRounded : '?';

This was implemented in https://github.com/phetsims/projectile-data-lab/issues/234. I'm not sure how to proceed.

samreid commented 2 weeks ago

@matthew-blackman recommended this patch:

```diff Subject: [PATCH] Avoid grunt, see https://github.com/phetsims/chipper/issues/1436 --- Index: repos/projectile-data-lab/wrappers/codap/codapWrapper.html IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/repos/projectile-data-lab/wrappers/codap/codapWrapper.html b/repos/projectile-data-lab/wrappers/codap/codapWrapper.html --- a/repos/projectile-data-lab/wrappers/codap/codapWrapper.html (revision 5e758c1641c02fb5b2bce3bf3efe8a42a9b79104) +++ b/repos/projectile-data-lab/wrappers/codap/codapWrapper.html (date 1731358977956) @@ -300,7 +300,12 @@ const launcherMechanismName = projectile.launcherMechanism.phetioID.substring( projectile.launcherMechanism.phetioID.lastIndexOf( '.' ) + 1 ); const launcherMechanism = launcherName === 'custom' ? launcherMechanismName : '?'; - const angleStabilitySliderValue = ( 5 - 0.2 ) / ( 5 - 0.2 ) * ( projectile.launcherStandardDeviationAngle - 5 ) + 0.2; + + // Determine the angle stability from the launcher standard deviation angle + const launcherStandardDeviationAngle = projectile.launcherStandardDeviationAngle; + const linear = ( a1, a2, b1, b2, a3 ) => ( b2 - b1 ) / ( a2 - a1 ) * ( a3 - a1 ) + b1; + const angleStabilitySliderValue = linear( 5, 0.2, 0, 1, launcherStandardDeviationAngle ); + const angleStabilityRounded = valueRoundedToThousandths( angleStabilitySliderValue ); const angleStability = launcherName === 'custom' ? angleStabilityRounded : '?';
samreid commented 2 weeks ago

After the commit, I'm seeing values from 0 (low stability) to 1 (high stability)

image