Skip to content

Commit

Permalink
Adding multiple bloch sphere nodes #54
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Jan 6, 2025
1 parent 0fca8c1 commit 069520e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions js/bloch-sphere/view/BlochSphereMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,31 @@ export default class BlochSphereMeasurementArea extends Node {
drawTitle: false,
drawKets: false,
drawAngleIndicators: true,
centerX: magneticFieldNode.centerX,
centerY: magneticFieldNode.centerY
center: magneticFieldNode.center,
visibleProperty: model.isSingleMeasurementModeProperty
} );
this.addChild( singleMeasurementBlochSphereNode );

const multipleMeasurementBlochSpheresTandem = providedOptions.tandem.createTandem( 'multipleMeasurementBlochSpheres' );
const multipleMeasurementBlochSpheresNode = new Node( {
visibleProperty: DerivedProperty.not( model.isSingleMeasurementModeProperty )
} );
const blochSpheresSpacing = 70;
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
} );
multipleMeasurementBlochSpheresNode.addChild( blochSphereNode );
} );
multipleMeasurementBlochSpheresNode.center = magneticFieldNode.center.plusXY( 0, 30 );
this.addChild( multipleMeasurementBlochSpheresNode );

const spinUpLabelStringProperty = new DerivedStringProperty(
[ model.measurementBasisProperty ],
measurementBasis => measurementBasis.label.value + QuantumMeasurementConstants.SPIN_UP_ARROW_CHARACTER
Expand Down

0 comments on commit 069520e

Please sign in to comment.