Skip to content

Commit

Permalink
Shear the force diagram for phetsims/buoyancy#12
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Jul 27, 2021
1 parent b61a7c3 commit 4192f05
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion js/common/view/DensityBuoyancyScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import DynamicProperty from '../../../../axon/js/DynamicProperty.js';
import Property from '../../../../axon/js/Property.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import Matrix3 from '../../../../dot/js/Matrix3.js';
import Plane3 from '../../../../dot/js/Plane3.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import Vector3 from '../../../../dot/js/Vector3.js';
Expand Down Expand Up @@ -639,7 +640,16 @@ class DensityBuoyancyScreenView extends ScreenView {
forceDiagramNode.update();

const mass = forceDiagramNode.mass;
forceDiagramNode.translation = this.modelToViewPoint( mass.matrix.translation.toVector3().plus( mass.forceOffsetProperty.value ) );
const originPoint = this.modelToViewPoint( mass.matrix.translation.toVector3().plus( mass.forceOffsetProperty.value ) );
const upOffsetPoint = this.modelToViewPoint( mass.matrix.translation.toVector3().plus( mass.forceOffsetProperty.value ).plusXYZ( 0, 1, 0 ) );

// Shear the force diagram so that it aligns with the perspective at the point, see
// https://github.com/phetsims/buoyancy/issues/12
forceDiagramNode.matrix = Matrix3.rowMajor(
1, ( upOffsetPoint.x - originPoint.x ) / ( upOffsetPoint.y - originPoint.y ), originPoint.x,
0, 1, originPoint.y,
0, 0, 1
);
} );

this.massLabelNodes.forEach( massLabelNode => {
Expand Down

0 comments on commit 4192f05

Please sign in to comment.