From 0d8517e6d1500d42f1da01556a13ec0f985ce5d2 Mon Sep 17 00:00:00 2001 From: AgustinVallejo Date: Fri, 17 Jan 2025 14:20:01 -0500 Subject: [PATCH] Changes to multi bloch sphere, see https://github.com/phetsims/quantum-measurement/issues/80 --- .../view/BlochSphereMeasurementArea.ts | 2 ++ js/common/view/BlochSphereNode.ts | 21 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/js/bloch-sphere/view/BlochSphereMeasurementArea.ts b/js/bloch-sphere/view/BlochSphereMeasurementArea.ts index 8875e02..e20242a 100644 --- a/js/bloch-sphere/view/BlochSphereMeasurementArea.ts +++ b/js/bloch-sphere/view/BlochSphereMeasurementArea.ts @@ -102,6 +102,8 @@ export default class BlochSphereMeasurementArea extends Node { drawTitle: false, drawKets: false, drawAngleIndicators: true, + drawAxesLabels: false, + stateVectorScale: 2, centerX: currentColumn * blochSpheresSpacing, centerY: currentRow * blochSpheresSpacing } ); diff --git a/js/common/view/BlochSphereNode.ts b/js/common/view/BlochSphereNode.ts index 57a62ad..e81fc04 100644 --- a/js/common/view/BlochSphereNode.ts +++ b/js/common/view/BlochSphereNode.ts @@ -30,6 +30,8 @@ type SelfOptions = { drawKets?: boolean; drawTitle?: boolean; drawAngleIndicators?: boolean; + drawAxesLabels?: boolean; + stateVectorScale?: number; // Scale for the vector's widths (head, body, etc) expandBounds?: boolean; }; export type BlochSphereNodeOptions = SelfOptions & WithRequired; @@ -64,8 +66,10 @@ export default class BlochSphereNode extends Node { drawKets: true, drawTitle: true, drawAngleIndicators: false, + drawAxesLabels: true, expandBounds: true, - excludeInvisibleChildrenFromBounds: true + excludeInvisibleChildrenFromBounds: true, + stateVectorScale: 1 }, providedOptions ); const sphereRadius = 100; @@ -107,17 +111,20 @@ export default class BlochSphereNode extends Node { const xAxisLabel = new Text( '+X', { fill: 'black', - font: LABELS_FONT + font: LABELS_FONT, + visible: options.drawAxesLabels } ); const yAxisLabel = new Text( 'Y', { fill: 'black', - font: LABELS_FONT + font: LABELS_FONT, + visible: options.drawAxesLabels } ); const zAxisLabel = new Text( 'Z', { centerX: -2 * LABELS_OFFSET, centerY: -sphereRadius + LABELS_OFFSET, fill: 'black', - font: LABELS_FONT + font: LABELS_FONT, + visible: options.drawAxesLabels } ); const UP = QuantumMeasurementConstants.SPIN_UP_ARROW_CHARACTER; @@ -152,9 +159,9 @@ export default class BlochSphereNode extends Node { } ); const stateVector = new ArrowNode( 0, 0, 0, -sphereRadius, { tandem: options.tandem.createTandem( 'stateVector' ), - headWidth: 10, - headHeight: 10, - tailWidth: 3, + headWidth: 10 * options.stateVectorScale, + headHeight: 10 * options.stateVectorScale, + tailWidth: 3 * options.stateVectorScale, fill: 'black', visibleProperty: stateVectorVisibleProperty } );