Skip to content

Commit

Permalink
Changes to multi bloch sphere, see #80
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Jan 17, 2025
1 parent cc49ca0 commit 0d8517e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions js/bloch-sphere/view/BlochSphereMeasurementArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
} );
Expand Down
21 changes: 14 additions & 7 deletions js/common/view/BlochSphereNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeOptions, 'tandem'>;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
} );
Expand Down

0 comments on commit 0d8517e

Please sign in to comment.