Optics & Lens Calculator
Build an app that uses the lens formula and mirror formula to find image distance, magnification, and determines the nature of the image (real/virtual, inverted/upright, magnified/diminished).
π― Learning Goals
- βΉ Master the Lens and Mirror equations (1/f = 1/v Β± 1/u)
- βΉ Apply Sign Convention rules accurately
- βΉ Understand Image properties and Magnification
- βΉ Build multi-mode tools for different optical components
π Why This Matters
Optical physics is why we have cameras, microscopes, telescopes, and corrective eyeglasses. Every time you take a photo on your phone, the device is using these exact formulas to focus the image on the sensor.
πUnderstanding Optics β Lenses & Mirrors
Theory MasterclassOptics is the branch of physics that studies light and its behavior with mirrors and lenses. Lens Formula: 1/v - 1/u = 1/f Mirror Formula: 1/v + 1/u = 1/f Where: u = Object distance (always negative for real objects in sign convention) v = Image distance f = Focal length (positive for convex lens/concave mirror, negative for concave lens/convex mirror) Sign Convention (New Cartesian): - All distances measured from the optical center/pole - Direction of incident light is positive - Object distance (u) is always negative (object is on the left) Magnification: For lens: m = v/u For mirror: m = -v/u Nature of Image: |m| > 1 β Magnified (image is bigger) |m| < 1 β Diminished (image is smaller) |m| = 1 β Same size m > 0 β Erect (upright) m < 0 β Inverted v > 0 β Real image (lens) / Virtual image (mirror) v < 0 β Virtual image (lens) / Real image (mirror)
Mathematical Foundation
π¨Part A β Designer View (UI Design)
Open MIT App Inventor β Switch to Designer view. Follow each step below to build the interface.
Set up with type selector
Title: "Optics Calculator" Add HorizontalArrangement: "Lens" and "Mirror" toggle buttons. Add a sub-selector: "Convex" and "Concave" buttons.
Create input section
Label: "Enter any TWO values (leave one empty to find it)" TextBox: "Object distance u (cm)" β Hint: "e.g., -30" TextBox: "Image distance v (cm)" TextBox: "Focal length f (cm)" Note: Remind students about sign convention in a Label.
Add Calculate button
Big "Calculate" button. Below it, add a "Sign Convention Guide" button that shows a popup explaining the rules.
Create results display
Labels for: - ImageDistanceLabel: "v = __ cm" - MagnificationLabel: "m = __" - NatureLabel: "Real / Virtual" - OrientationLabel: "Inverted / Erect" - SizeLabel: "Magnified / Diminished / Same size" - PowerLabel: "Power = __ diopters"
π§©Part B β Blocks View (Logic & Calculation)
Switch to Blocks view. Now add the logic that makes your app actually work.
Determine which value to calculate
When CalculateButton.Click: Check which TextBox is empty: - If u is empty β Calculate u from v and f - If v is empty β Calculate v from u and f - If f is empty β Calculate f from u and v
Lens formula calculation
If mode = "Lens": 1/v - 1/u = 1/f To find v: 1/v = 1/f + 1/u β v = 1/(1/f + 1/u) To find u: 1/u = 1/v - 1/f β u = 1/(1/v - 1/f) To find f: 1/f = 1/v - 1/u β f = 1/(1/v - 1/u) Check for division by zero at each step!
Mirror formula calculation
If mode = "Mirror": 1/v + 1/u = 1/f To find v: 1/v = 1/f - 1/u β v = 1/(1/f - 1/u) To find u: 1/u = 1/f - 1/v β u = 1/(1/f - 1/v) To find f: 1/f = 1/v + 1/u β f = 1/(1/v + 1/u)
Calculate magnification
If lens: m = v / u If mirror: m = -(v / u) Display the magnification value.
Determine image nature
For Lens: if v > 0 β "Real Image" else β "Virtual Image" For Mirror: if v < 0 β "Real Image" else β "Virtual Image" if m > 0 β "Erect" else β "Inverted" if abs(m) > 1 β "Magnified" if abs(m) < 1 β "Diminished" if abs(m) = 1 β "Same Size"
Calculate lens power
If in lens mode: Power = 100 / f (when f is in cm, convert to meters by dividing by 100) Actually: Power = 1 / (f/100) = 100/f Display: "Power = " + P + " diopters" Positive power = converging lens Negative power = diverging lens
Sign Convention helper
When SignConventionButton.Click: Show Notifier with message: "SIGN CONVENTION: - Object distance (u) is always NEGATIVE - Focal length: POSITIVE for convex lens/concave mirror - Focal length: NEGATIVE for concave lens/convex mirror - Measure all distances from the center of the lens/mirror"
π§ͺTesting Your App
- βConvex lens: u=-30, f=15 β v=30, m=-1 (real, inverted, same size)
- βConvex lens: u=-20, f=15 β v=60, m=-3 (real, inverted, magnified)
- βConvex lens: u=-10, f=15 β v=-30, m=3 (virtual, erect, magnified)
- βConcave mirror: u=-20, f=-15 β check the nature of image
- βObject at 2f: image at 2f, same size, real, inverted
πBonus Challenges
Extra credit β impress your instructor
- β Draw a ray diagram on Canvas showing the object, lens/mirror, and image
- β Add a mode for two thin lenses in contact: 1/f = 1/fβ + 1/fβ
- β Create a table showing image positions for objects at F, 2F, β, etc.
- β Add Snell's Law calculator: nβsinΞΈβ = nβsinΞΈβ