Skip to content

Commit

Permalink
first pass at flat mirror, using a concave mirror with very large ROC,
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Feb 22, 2022
1 parent 986b8ef commit 7cc92bc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
27 changes: 20 additions & 7 deletions js/common/model/Optic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ import { FocalLengthControlType } from './FocalLengthControlType.js';
import DirectFocalLengthModel, { DirectFocalLengthModelOptions } from './DirectFocalLengthModel.js';
import IndirectFocalLengthModel, { IndirectFocalLengthModelOptions } from './IndirectFocalLengthModel.js';

const EFFECTIVELY_INFINITE_ROC = -200000; // negative, to make it concave
const EFFECTIVELY_INFINITE_FOCAL_LENGTH = EFFECTIVELY_INFINITE_ROC / 2;

type OpticOptions = {

// initial shape of the optic, 'convex' or 'concave'
opticShape: OpticShape,

// supported values of OpticShape, in the left-to-right order that they appear as radio buttons
// supported values of OpticShape, radio buttons will be created left-to-right in this order
opticShapes: OpticShape[]

// range of diameter, in cm
Expand Down Expand Up @@ -194,9 +197,14 @@ abstract class Optic extends PhetioObject {
focalLengthControlType: string,
directRadiusOfCurvatureMagnitude: number,
indirectRadiusOfCurvatureMagnitude: number ) => {
const sign = ( opticShape === 'convex' ) ? 1 : -1;
const magnitude = ( focalLengthControlType === 'direct' ) ? directRadiusOfCurvatureMagnitude : indirectRadiusOfCurvatureMagnitude;
return sign * magnitude;
if ( opticShape === 'flat' ) {
return EFFECTIVELY_INFINITE_ROC;
}
else {
const sign = ( opticShape === 'convex' ) ? 1 : -1;
const magnitude = ( focalLengthControlType === 'direct' ) ? directRadiusOfCurvatureMagnitude : indirectRadiusOfCurvatureMagnitude;
return sign * magnitude;
}
}, {
units: 'cm',
tandem: options.tandem.createTandem( 'radiusOfCurvatureProperty' ),
Expand Down Expand Up @@ -228,9 +236,14 @@ abstract class Optic extends PhetioObject {
focalLengthControlType: string,
directFocalLengthMagnitude: number,
indirectFocalLengthMagnitude: number ) => {
const sign = this.isConverging( opticShape ) ? 1 : -1;
const magnitude = ( focalLengthControlType === 'direct' ) ? directFocalLengthMagnitude : indirectFocalLengthMagnitude;
return sign * magnitude;
if ( opticShape === 'flat' ) {
return EFFECTIVELY_INFINITE_FOCAL_LENGTH;
}
else {
const sign = this.isConverging( opticShape ) ? 1 : -1;
const magnitude = ( focalLengthControlType === 'direct' ) ? directFocalLengthMagnitude : indirectFocalLengthMagnitude;
return sign * magnitude;
}
}, {
units: 'cm',
tandem: options.tandem.createTandem( 'focalLengthProperty' ),
Expand Down
2 changes: 1 addition & 1 deletion js/lens/model/Lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Lens extends Optic {

const options = merge( {
opticShape: 'convex',
opticShapes: [ 'convex', 'concave' ],
opticShapes: [ 'convex', 'concave' ], // radio buttons will be created left-to-right in this order
diameterRange: GOConstants.DIAMETER_RANGE, // in cm
sign: 1,
directFocalLengthModelOptions: {
Expand Down
2 changes: 1 addition & 1 deletion js/mirror/model/Mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Mirror extends Optic {

const options = merge( {
opticShape: 'concave',
opticShapes: [ 'concave', 'convex' ], //TODO https://github.com/phetsims/geometric-optics/issues/227 add 'flat'
opticShapes: [ 'concave', 'convex', 'flat' ], // radio buttons will be created left-to-right in this order
diameterRange: GOConstants.DIAMETER_RANGE, // in cm
sign: -1,
directFocalLengthModelOptions: {
Expand Down
8 changes: 6 additions & 2 deletions js/mirror/view/MirrorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import merge from '../../../../phet-core/js/merge.js';
const FILL = GOColors.mirrorBackingColorProperty;
const STROKE = GOColors.mirrorReflectiveCoatingColorProperty;
const LINE_WIDTH = 2;
const ICON_RADIUS_OF_CURVATURE_MAGNITUDE = 20;
const ICON_EFFECTIVELY_INFINITE_RADIUS_OF_CURVATURE_MAGNITUDE = -200000;
const ICON_CONVEX_RADIUS_OF_CURVATURE_MAGNITUDE = 20;
const ICON_CONCAVE_RADIUS_OF_CURVATURE_MAGNITUDE = -ICON_CONVEX_RADIUS_OF_CURVATURE_MAGNITUDE;
const ICON_DIAMETER = 30;

type MirrorNodeOptions = {
Expand Down Expand Up @@ -95,7 +97,9 @@ class MirrorNode extends Node {
*/
public static createIconNode( opticShape: OpticShape ): Node {

const radiusOfCurvature = ( opticShape === 'convex' ) ? ICON_RADIUS_OF_CURVATURE_MAGNITUDE : -ICON_RADIUS_OF_CURVATURE_MAGNITUDE;
const radiusOfCurvature = ( opticShape === 'flat' ) ? ICON_EFFECTIVELY_INFINITE_RADIUS_OF_CURVATURE_MAGNITUDE :
( opticShape === 'convex' ) ? ICON_CONVEX_RADIUS_OF_CURVATURE_MAGNITUDE :
ICON_CONCAVE_RADIUS_OF_CURVATURE_MAGNITUDE;

const mirrorShapes = new MirrorShapes( radiusOfCurvature, ICON_DIAMETER, {
backingThickness: 4 // cm
Expand Down

0 comments on commit 7cc92bc

Please sign in to comment.