Skip to content

Commit

Permalink
Doing the lattice pattern for the multiple bloch spheres, see #54
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Jan 15, 2025
1 parent 6f168ed commit d8e13a9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions js/bloch-sphere/view/BlochSphereMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,26 @@ export default class BlochSphereMeasurementArea extends Node {
visibleProperty: DerivedProperty.not( model.isSingleMeasurementModeProperty )
} );
const blochSpheresSpacing = 70;
const lattice = [ 3, 2, 3, 2 ];
let currentRow = 0;
let currentColumn = 0;
model.multiMeasurementBlochSpheres.forEach( ( blochSphere, index ) => {
const blochSphereNode = new BlochSphereNode( blochSphere, {
tandem: multipleMeasurementBlochSpheresTandem.createTandem( `blochSphere${index}` ),
scale: 0.3,
drawTitle: false,
drawKets: false,
drawAngleIndicators: true,
centerX: index !== 9 ? ( ( index + 1 ) % 3 ) * blochSpheresSpacing : blochSpheresSpacing,
centerY: Math.floor( index / 3 ) * blochSpheresSpacing
centerX: currentColumn * blochSpheresSpacing,
centerY: currentRow * blochSpheresSpacing
} );
multipleMeasurementBlochSpheresNode.addChild( blochSphereNode );

currentColumn++;
if ( currentColumn >= lattice[ currentRow % lattice.length ] ) {
currentColumn = lattice[ currentRow % lattice.length ] === 3 ? 0.5 : 0;
currentRow++;
}
} );
multipleMeasurementBlochSpheresNode.center = magneticFieldNode.center.plusXY( 0, 30 );

Expand Down

0 comments on commit d8e13a9

Please sign in to comment.