From 5e974ea9c7f68a3c9cffa3a51f6c6ea1e58e2e8a Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Sun, 8 Mar 2026 01:55:19 +0000 Subject: [PATCH] Add next calculators set with flow, magnetism, and EV conversions --- calculators_list.md | 155 +++++++++++++----------- hdyc-svelte/src/lib/data/calculators.ts | 37 +++++- hdyc-svelte/src/lib/engine.ts | 63 ++++++++-- migrate.py | 8 +- 4 files changed, 174 insertions(+), 89 deletions(-) diff --git a/calculators_list.md b/calculators_list.md index 5949a7c..1071429 100644 --- a/calculators_list.md +++ b/calculators_list.md @@ -1748,40 +1748,40 @@ The registry currently contains 1333 unique calculator slugs. | Speed Of Light (c) to Miles Per Hour – Express c in miles per hour for familiar velocity comparisons. | speed-of-light-c-to-miles-per-hour | 670616629.384 | | Speed Of Light (c) to Speed Of Light – Reference the c constant as itself. | speed-of-light-c-to-speed-of-light | 1 | | Speed Of Light (c) to Yards Per Second – Show c as yards per second for track-level perspective. | speed-of-light-c-to-yards-per-second | 327857018.81 | -| Ampere-turns to Gilberts – Convert SI magnetomotive force into the CGS gilbert unit used for coils. | ampere-turns-to-gilberts | 0.7957747155 | -| Gilberts to Ampere-turns – Translate the historical gilbert into modern ampere-turns. | gilberts-to-ampere-turns | 1.2566370614 | -| Ampere per meter to Oersted – Express magnetic field strength in CGS oersteds. | ampere-per-meter-to-oersted | 0.0125663706 | -| Oersted to Ampere per meter – Bring Oersted readings into SI amperes per meter. | oersted-to-ampere-per-meter | 79.577471546 | -| Weber to Maxwell – Translate SI magnetic flux into cgs maxwells. | weber-to-maxwell | 1e8 | -| Maxwell to Weber – Return century-old maxwell flux back into webers. | maxwell-to-weber | 1e-8 | -| Tesla to Gauss – Express magnetic flux density in gauss when referencing laboratory magnets. | tesla-to-gauss | 10000 | -| Gauss to Tesla – Turn gauss into tesla for SI calculations. | gauss-to-tesla | 0.0001 | -| Tesla to Millitesla – Use the millitesla scale for engineering magnets. | tesla-to-millitesla | 1000 | -| Millitesla to Tesla – Convert millitesla readings back into tesla. | millitesla-to-tesla | 0.001 | -| Tesla to Kilogauss – Translate tesla directly to kilogauss for chart comparisons. | tesla-to-kilogauss | 10 | -| Kilogauss to Tesla – Return kilogauss values back into tesla. | kilogauss-to-tesla | 0.1 | -| Cubic meters per second to Liters per minute – Turn volumetric flow rates into convenient liters/minute values. | cubic-meters-per-second-to-liters-per-minute | 60000 | -| Liters per minute to Gallons per minute – Express liters/min as US gallons/min for flow metering. | liters-per-minute-to-gallons-per-minute | 0.264172052 | -| Kilograms per second to Pounds per hour – Convert mass flow from the SI kilogram scale to imperial pounds per hour. | kilograms-per-second-to-pounds-per-hour | 7936.641761 | -| Pounds per hour to Kilograms per second – Bring imperial mass flow back into the SI kilogram rate. | pounds-per-hour-to-kilograms-per-second | 0.000126577 | -| Moles per second to Moles per hour – Translate molar flow between seconds and hours. | moles-per-second-to-moles-per-hour | 3600 | -| Moles per hour to Moles per second – Return molar flow rates back to per-second units. | moles-per-hour-to-moles-per-second | 0.0002777778 | -| Kilograms per second per square meter to Grams per second per square centimeter – Express mass flux density using metric subunits. | kilograms-per-second-per-square-meter-to-grams-per-second-per-square-centimeter | 0.1 | -| Grams per second per square centimeter to Kilograms per second per square meter – Convert compact mass flux into the SI-friendly base. | grams-per-second-per-square-centimeter-to-kilograms-per-second-per-square-meter | 10 | -| Mol per cubic meter to mmol per liter – Translate molar concentrations across common volume units. | mol-per-cubic-meter-to-mmol-per-liter | 1 | -| mmol per liter to mol per cubic meter – Convert molar concentration back into SI cubic meters. | mmol-per-liter-to-mol-per-cubic-meter | 1 | -| Percent by mass to ppm – Turn mass-percent concentrations into parts-per-million. | percent-by-mass-to-ppm | 10000 | -| ppm to Percent by mass – Return ppm values to mass-percent. | ppm-to-percent-by-mass | 0.0001 | -| Pascal-second to Poise – Convert SI dynamic viscosity into CGS poise. | pascal-second-to-poise | 10 | -| Poise to Pascal-second – Bring poise measurements back into pascal-seconds. | poise-to-pascal-second | 0.1 | -| Pascal-second to Centipoise – Express pascal-seconds as centipoise for lab viscosity. | pascal-second-to-centipoise | 100 | -| Centipoise to Pascal-second – Convert centipoise into pascal-seconds. | centipoise-to-pascal-second | 0.01 | -| Square meter per second to Centistokes – Translate kinematic viscosity into centistokes. | square-meter-per-second-to-centistokes | 100 | -| Centistokes to Square meter per second – Return centistokes back to base square meters per second. | centistokes-to-square-meter-per-second | 0.01 | -| Newton per meter to Dyne per centimeter – Express surface tension on the CGS scale. | newton-per-meter-to-dyne-per-centimeter | 1000 | -| Dyne per centimeter to Newton per meter – Convert surface tension back into SI. | dyne-per-centimeter-to-newton-per-meter | 0.001 | -| Henry per meter to Tesla-meter per ampere – Equate magnetic permeability units across SI conventions. | henry-per-meter-to-tesla-meter-per-ampere | 1 | -| Tesla-meter per ampere to Henry per meter – Return permeability back to henry per meter. | tesla-meter-per-ampere-to-henry-per-meter | 1 | +| Ampere-turns to Gilberts – Convert SI magnetomotive force into the CGS gilbert unit used for coils. | ampere-turns-to-gilberts | magnetism | 0.7957747155 | +| Gilberts to Ampere-turns – Translate the historical gilbert into modern ampere-turns. | gilberts-to-ampere-turns | magnetism | 1.2566370614 | +| Ampere per meter to Oersted – Express magnetic field strength in CGS oersteds. | ampere-per-meter-to-oersted | magnetism | 0.0125663706 | +| Oersted to Ampere per meter – Bring Oersted readings into SI amperes per meter. | oersted-to-ampere-per-meter | magnetism | 79.577471546 | +| Weber to Maxwell – Translate SI magnetic flux into cgs maxwells. | weber-to-maxwell | magnetism | 1e8 | +| Maxwell to Weber – Return century-old maxwell flux back into webers. | maxwell-to-weber | magnetism | 1e-8 | +| Tesla to Gauss – Express magnetic flux density in gauss when referencing laboratory magnets. | tesla-to-gauss | magnetism | 10000 | +| Gauss to Tesla – Turn gauss into tesla for SI calculations. | gauss-to-tesla | magnetism | 0.0001 | +| Tesla to Millitesla – Use the millitesla scale for engineering magnets. | tesla-to-millitesla | magnetism | 1000 | +| Millitesla to Tesla – Convert millitesla readings back into tesla. | millitesla-to-tesla | magnetism | 0.001 | +| Tesla to Kilogauss – Translate tesla directly to kilogauss for chart comparisons. | tesla-to-kilogauss | magnetism | 10 | +| Kilogauss to Tesla – Return kilogauss values back into tesla. | kilogauss-to-tesla | magnetism | 0.1 | +| Cubic meters per second to Liters per minute – Turn volumetric flow rates into convenient liters/minute values. | cubic-meters-per-second-to-liters-per-minute | fluids | 60000 | +| Liters per minute to Gallons per minute – Express liters/min as US gallons/min for flow metering. | liters-per-minute-to-gallons-per-minute | fluids | 0.264172052 | +| Kilograms per second to Pounds per hour – Convert mass flow from the SI kilogram scale to imperial pounds per hour. | kilograms-per-second-to-pounds-per-hour | weight | 7936.641761 | +| Pounds per hour to Kilograms per second – Bring imperial mass flow back into the SI kilogram rate. | pounds-per-hour-to-kilograms-per-second | weight | 0.000126577 | +| Moles per second to Moles per hour – Translate molar flow between seconds and hours. | moles-per-second-to-moles-per-hour | other | 3600 | +| Moles per hour to Moles per second – Return molar flow rates back to per-second units. | moles-per-hour-to-moles-per-second | other | 0.0002777778 | +| Kilograms per second per square meter to Grams per second per square centimeter – Express mass flux density using metric subunits. | kilograms-per-second-per-square-meter-to-grams-per-second-per-square-centimeter | other | 0.1 | +| Grams per second per square centimeter to Kilograms per second per square meter – Convert compact mass flux into the SI-friendly base. | grams-per-second-per-square-centimeter-to-kilograms-per-second-per-square-meter | other | 10 | +| Mol per cubic meter to mmol per liter – Translate molar concentrations across common volume units. | mol-per-cubic-meter-to-mmol-per-liter | fluids | 1 | +| mmol per liter to mol per cubic meter – Convert molar concentration back into SI cubic meters. | mmol-per-liter-to-mol-per-cubic-meter | fluids | 1 | +| Percent by mass to ppm – Turn mass-percent concentrations into parts-per-million. | percent-by-mass-to-ppm | other | 10000 | +| ppm to Percent by mass – Return ppm values to mass-percent. | ppm-to-percent-by-mass | other | 0.0001 | +| Pascal-second to Poise – Convert SI dynamic viscosity into CGS poise. | pascal-second-to-poise | pressure | 10 | +| Poise to Pascal-second – Bring poise measurements back into pascal-seconds. | poise-to-pascal-second | pressure | 0.1 | +| Pascal-second to Centipoise – Express pascal-seconds as centipoise for lab viscosity. | pascal-second-to-centipoise | pressure | 100 | +| Centipoise to Pascal-second – Convert centipoise into pascal-seconds. | centipoise-to-pascal-second | pressure | 0.01 | +| Square meter per second to Centistokes – Translate kinematic viscosity into centistokes. | square-meter-per-second-to-centistokes | other | 100 | +| Centistokes to Square meter per second – Return centistokes back to base square meters per second. | centistokes-to-square-meter-per-second | other | 0.01 | +| Newton per meter to Dyne per centimeter – Express surface tension on the CGS scale. | newton-per-meter-to-dyne-per-centimeter | force | 1000 | +| Dyne per centimeter to Newton per meter – Convert surface tension back into SI. | dyne-per-centimeter-to-newton-per-meter | force | 0.001 | +| Henry per meter to Tesla-meter per ampere – Equate magnetic permeability units across SI conventions. | henry-per-meter-to-tesla-meter-per-ampere | magnetism | 1 | +| Tesla-meter per ampere to Henry per meter – Return permeability back to henry per meter. | tesla-meter-per-ampere-to-henry-per-meter | magnetism | 1 | | Speed Of Light to Centimeters Per Second – Express the speed of light as centimeters per second. | speed-of-light-to-centimeters-per-second | 29979245800 | | Speed Of Light to Cm Per Second – Alias referencing cm/s for the same throughput. | speed-of-light-to-cm-per-second | 29979245800 | | Speed Of Light to Feet Per Second – Show c in feet per second for mechanical intuition. | speed-of-light-to-feet-per-second | 983571056.43 | @@ -1908,6 +1908,13 @@ The registry currently contains 1333 unique calculator slugs. | AWG to Square millimeters (cross-section) – Convert AWG sizes into cross-sectional area in mm². | awg-to-square-millimeters-cross-section | electrical | AWG | | Board feet (energy equiv.) to BTU – Convert the energy equivalent of a board foot of lumber into BTUs. | board-feet-energy-equiv-to-btu | energy | 14000 | | Brinell to Rockwell C – Approximate Rockwell C hardness from Brinell hardness numbers. | brinell-to-rockwell-c | other | Formula | +| Cloves to Kilograms – Convert traditional clove mass into kilograms. | cloves-to-kilograms | weight | 3.62873896 | +| Em to Pixels – Convert CSS em units to pixels assuming a 16px base size. | em-to-pixels | other | 16 | +| EV (exposure value) to Lux – Estimate scene illuminance at ISO 100. | ev-to-lux | light | EV | +| Lux to EV – Convert lux readings to exposure value at ISO 100. | lux-to-ev | light | EV | +| f-stops to T-stops – Treat f-number as t-stop under ideal transmission. | f-stops-to-t-stops | other | 1 | +| Focal length to Angle of view – Approximate horizontal angle on 35mm full-frame (36mm width). | focal-length-to-angle-of-view | other | AOV | +| Millimeters to AWG – Convert conductor diameter in millimeters to AWG gauge. | millimeters-to-awg | electrical | AWG | ## Completion Checklist - [x] Inches to Feet (`inches-to-feet`) @@ -3044,40 +3051,40 @@ The registry currently contains 1333 unique calculator slugs. - [x] Heat transfer coefficient (W/(m²·K)) to W/(ft²·°F) (`heat-transfer-coefficient-w-per-square-meter-k-to-w-per-square-foot-f`) - [x] Heat transfer coefficient (W/(ft²·°F)) to W/(m²·K) (`heat-transfer-coefficient-w-per-square-foot-f-to-w-per-square-meter-k`) - [x] Ampere-turns to Gilberts (`ampere-turns-to-gilberts`) -- [ ] Gilberts to Ampere-turns (`gilberts-to-ampere-turns`) -- [ ] Ampere per meter to Oersted (`ampere-per-meter-to-oersted`) -- [ ] Oersted to Ampere per meter (`oersted-to-ampere-per-meter`) -- [ ] Weber to Maxwell (`weber-to-maxwell`) -- [ ] Maxwell to Weber (`maxwell-to-weber`) -- [ ] Tesla to Gauss (`tesla-to-gauss`) -- [ ] Gauss to Tesla (`gauss-to-tesla`) -- [ ] Tesla to Millitesla (`tesla-to-millitesla`) -- [ ] Millitesla to Tesla (`millitesla-to-tesla`) -- [ ] Tesla to Kilogauss (`tesla-to-kilogauss`) -- [ ] Kilogauss to Tesla (`kilogauss-to-tesla`) +- [x] Gilberts to Ampere-turns (`gilberts-to-ampere-turns`) +- [x] Ampere per meter to Oersted (`ampere-per-meter-to-oersted`) +- [x] Oersted to Ampere per meter (`oersted-to-ampere-per-meter`) +- [x] Weber to Maxwell (`weber-to-maxwell`) +- [x] Maxwell to Weber (`maxwell-to-weber`) +- [x] Tesla to Gauss (`tesla-to-gauss`) +- [x] Gauss to Tesla (`gauss-to-tesla`) +- [x] Tesla to Millitesla (`tesla-to-millitesla`) +- [x] Millitesla to Tesla (`millitesla-to-tesla`) +- [x] Tesla to Kilogauss (`tesla-to-kilogauss`) +- [x] Kilogauss to Tesla (`kilogauss-to-tesla`) -- [ ] Cubic meters per second to Liters per minute (`cubic-meters-per-second-to-liters-per-minute`) -- [ ] Liters per minute to Gallons per minute (`liters-per-minute-to-gallons-per-minute`) -- [ ] Kilograms per second to Pounds per hour (`kilograms-per-second-to-pounds-per-hour`) -- [ ] Pounds per hour to Kilograms per second (`pounds-per-hour-to-kilograms-per-second`) -- [ ] Moles per second to Moles per hour (`moles-per-second-to-moles-per-hour`) -- [ ] Moles per hour to Moles per second (`moles-per-hour-to-moles-per-second`) -- [ ] Kilograms per second per square meter to Grams per second per square centimeter (`kilograms-per-second-per-square-meter-to-grams-per-second-per-square-centimeter`) -- [ ] Grams per second per square centimeter to Kilograms per second per square meter (`grams-per-second-per-square-centimeter-to-kilograms-per-second-per-square-meter`) -- [ ] Mol per cubic meter to mmol per liter (`mol-per-cubic-meter-to-mmol-per-liter`) -- [ ] mmol per liter to Mol per cubic meter (`mmol-per-liter-to-mol-per-cubic-meter`) -- [ ] Percent by mass to ppm (`percent-by-mass-to-ppm`) -- [ ] ppm to Percent by mass (`ppm-to-percent-by-mass`) -- [ ] Pascal-second to Poise (`pascal-second-to-poise`) -- [ ] Poise to Pascal-second (`poise-to-pascal-second`) -- [ ] Pascal-second to Centipoise (`pascal-second-to-centipoise`) -- [ ] Centipoise to Pascal-second (`centipoise-to-pascal-second`) -- [ ] Square meter per second to Centistokes (`square-meter-per-second-to-centistokes`) -- [ ] Centistokes to Square meter per second (`centistokes-to-square-meter-per-second`) -- [ ] Newton per meter to Dyne per centimeter (`newton-per-meter-to-dyne-per-centimeter`) -- [ ] Dyne per centimeter to Newton per meter (`dyne-per-centimeter-to-newton-per-meter`) -- [ ] Henry per meter to Tesla-meter per ampere (`henry-per-meter-to-tesla-meter-per-ampere`) -- [ ] Tesla-meter per ampere to Henry per meter (`tesla-meter-per-ampere-to-henry-per-meter`) +- [x] Cubic meters per second to Liters per minute (`cubic-meters-per-second-to-liters-per-minute`) +- [x] Liters per minute to Gallons per minute (`liters-per-minute-to-gallons-per-minute`) +- [x] Kilograms per second to Pounds per hour (`kilograms-per-second-to-pounds-per-hour`) +- [x] Pounds per hour to Kilograms per second (`pounds-per-hour-to-kilograms-per-second`) +- [x] Moles per second to Moles per hour (`moles-per-second-to-moles-per-hour`) +- [x] Moles per hour to Moles per second (`moles-per-hour-to-moles-per-second`) +- [x] Kilograms per second per square meter to Grams per second per square centimeter (`kilograms-per-second-per-square-meter-to-grams-per-second-per-square-centimeter`) +- [x] Grams per second per square centimeter to Kilograms per second per square meter (`grams-per-second-per-square-centimeter-to-kilograms-per-second-per-square-meter`) +- [x] Mol per cubic meter to mmol per liter (`mol-per-cubic-meter-to-mmol-per-liter`) +- [x] mmol per liter to Mol per cubic meter (`mmol-per-liter-to-mol-per-cubic-meter`) +- [x] Percent by mass to ppm (`percent-by-mass-to-ppm`) +- [x] ppm to Percent by mass (`ppm-to-percent-by-mass`) +- [x] Pascal-second to Poise (`pascal-second-to-poise`) +- [x] Poise to Pascal-second (`poise-to-pascal-second`) +- [x] Pascal-second to Centipoise (`pascal-second-to-centipoise`) +- [x] Centipoise to Pascal-second (`centipoise-to-pascal-second`) +- [x] Square meter per second to Centistokes (`square-meter-per-second-to-centistokes`) +- [x] Centistokes to Square meter per second (`centistokes-to-square-meter-per-second`) +- [x] Newton per meter to Dyne per centimeter (`newton-per-meter-to-dyne-per-centimeter`) +- [x] Dyne per centimeter to Newton per meter (`dyne-per-centimeter-to-newton-per-meter`) +- [x] Henry per meter to Tesla-meter per ampere (`henry-per-meter-to-tesla-meter-per-ampere`) +- [x] Tesla-meter per ampere to Henry per meter (`tesla-meter-per-ampere-to-henry-per-meter`) - [x] Centigrams to Milligrams - [x] Centiliters to Milliliters @@ -3093,7 +3100,7 @@ The registry currently contains 1333 unique calculator slugs. - [x] Chains to Miles - [x] Chains to Yards - [x] Circular mils to Square mils -- [ ] Cloves to Kilograms +- [x] Cloves to Kilograms - [x] cm per second to Inches per second - [x] cmHg to Torr - [x] CMS to Liters per second @@ -3138,10 +3145,10 @@ The registry currently contains 1333 unique calculator slugs. - [x] Electrical Horsepower to Mechanical HP - [x] Electron-volts to Hartree - [x] Electron-volts to Joules -- [ ] Em to Pixels -- [ ] EV (exposure value) to Lux +- [x] Em to Pixels +- [x] EV (exposure value) to Lux - [x] Exabytes to Petabytes -- [ ] f-stops to T-stops +- [x] f-stops to T-stops - [x] Fahrenheit to Kelvin - [x] Fahrenheit to Newton (temp scale) - [x] Fahrenheit to Rankine @@ -3167,7 +3174,7 @@ The registry currently contains 1333 unique calculator slugs. - [x] Fluid Ounces to Liters - [x] Fluid Ounces to Tablespoons - [x] Fluid Ounces to Teaspoons -- [ ] Focal length to Angle of view +- [x] Focal length to Angle of view - [x] Kilometers to Yards (1 kilometer ≈ 1,093.61 yards) - [x] Kilonewtons to Newtons - [x] Kilopascals to Inches of Mercury @@ -3213,7 +3220,7 @@ The registry currently contains 1333 unique calculator slugs. - [x] Long Tons to Pounds - [x] Long Tons to Short Tons - [x] Lusec to Watts -- [ ] Lux to EV +- [x] Lux to EV - [x] Lux to Foot-candles - [x] Mach to Feet per second - [x] Mach to Kilometers per hour @@ -3284,7 +3291,7 @@ The registry currently contains 1333 unique calculator slugs. - [x] Milliliters to Drams (fluid) (`milliliters-to-drams-fluid`) - [x] Milliliters to Gill (`milliliters-to-gill`) - [x] Milliliters to Jiggers (`milliliters-to-jiggers`) -- [ ] Millimeters to AWG +- [x] Millimeters to AWG - [x] Millimeters to Thou (`millimeters-to-thou`) - [x] Millirem to Microsievert (`millirem-to-microsievert`) - [x] Milliseconds to Microseconds (`milliseconds-to-microseconds`) diff --git a/hdyc-svelte/src/lib/data/calculators.ts b/hdyc-svelte/src/lib/data/calculators.ts index d273ec5..f052a4c 100644 --- a/hdyc-svelte/src/lib/data/calculators.ts +++ b/hdyc-svelte/src/lib/data/calculators.ts @@ -1,5 +1,5 @@ // THIS FILE IS AUTO-GENERATED BY migrate.py -export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell'; +export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell' | 'ev-lux' | 'aov'; export interface CalculatorDef { slug: string; @@ -652,7 +652,7 @@ export const calculators: CalculatorDef[] = [ {"slug": "millimeters-to-microns", "name": "Millimeters to Microns", "category": "length", "type": "standard", "labels": {"in1": "Millimeters", "in2": "Microns"}, "factor": 1000.0}, {"slug": "femtograms-to-attograms", "name": "Femtograms to Attograms", "category": "weight", "type": "standard", "labels": {"in1": "Femtograms", "in2": "Attograms"}, "factor": 1000.0}, {"slug": "gigabytes-to-terabytes", "name": "Gigabytes to Terabytes", "category": "data", "type": "standard", "labels": {"in1": "Gigabytes", "in2": "Terabytes"}, "factor": 0.001}, - {"slug": "maxwell-to-weber", "name": "Maxwell to Weber", "category": "magnetism", "type": "standard", "teaser": "Convert CGS magnetic flux (maxwell) into SI webers.", "labels": {"in1": "Maxwell", "in2": "Weber"}, "factor": 1e-08}, + {"slug": "maxwell-to-weber", "name": "Maxwell to Weber", "category": "magnetism", "type": "standard", "teaser": "Convert CGS magnetic flux (maxwell) into SI webers.", "labels": {"in1": "Maxwell", "in2": "Weber"}, "factor": 1e-08, "hidden": true}, {"slug": "mbps-to-gbps", "name": "Mbps to Gbps", "category": "other", "type": "standard", "teaser": "Convert megabits per second into gigabits per second.", "labels": {"in1": "Mbps", "in2": "Gbps"}, "factor": 0.001, "hidden": true}, {"slug": "mbps-to-kbps", "name": "Mbps to Kbps", "category": "other", "type": "standard", "teaser": "Convert megabits per second into kilobits per second.", "labels": {"in1": "Mbps", "in2": "Kbps"}, "factor": 1000.0}, {"slug": "mbps-to-mb-per-second", "name": "Mbps to MB/s", "category": "other", "type": "standard", "teaser": "Convert megabits per second into megabytes per second.", "labels": {"in1": "Mbps", "in2": "MB/s"}, "factor": 0.125}, @@ -1598,11 +1598,44 @@ export const calculators: CalculatorDef[] = [ {"slug": "heat-transfer-coefficient-btu-per-hour-square-foot-f-to-w-per-square-meter-k", "name": "Heat transfer coefficient (BTU/(hr\u00b7ft\u00b2\u00b7\u00b0F)) to W/(m\u00b2\u00b7K)", "category": "energy", "type": "standard", "teaser": "Return imperial coefficients back into SI.", "labels": {"in1": "Heat transfer coefficient (BTU/(hr\u00b7ft\u00b2\u00b7\u00b0F))", "in2": "W/(m\u00b2\u00b7K)"}, "factor": 5.6782633415}, {"slug": "heat-transfer-coefficient-w-per-square-meter-k-to-w-per-square-foot-f", "name": "Heat transfer coefficient (W/(m\u00b2\u00b7K)) to W/(ft\u00b2\u00b7\u00b0F)", "category": "energy", "type": "standard", "teaser": "Move the conduction coefficient into mixed-area and temperature units.", "labels": {"in1": "Heat transfer coefficient (W/(m\u00b2\u00b7K))", "in2": "W/(ft\u00b2\u00b7\u00b0F)"}, "factor": 0.0516128}, {"slug": "heat-transfer-coefficient-w-per-square-foot-f-to-w-per-square-meter-k", "name": "Heat transfer coefficient (W/(ft\u00b2\u00b7\u00b0F)) to W/(m\u00b2\u00b7K)", "category": "energy", "type": "standard", "teaser": "Convert the mixed imperial SI coefficient back into its base units.", "labels": {"in1": "Heat transfer coefficient (W/(ft\u00b2\u00b7\u00b0F))", "in2": "W/(m\u00b2\u00b7K)"}, "factor": 19.3750387506}, + {"slug": "ampere-turns-to-gilberts", "name": "Ampere-turns to Gilberts", "category": "magnetism", "type": "standard", "teaser": "Convert SI magnetomotive force into the CGS gilbert unit used for coils.", "labels": {"in1": "Ampere-turns", "in2": "Gilberts"}, "factor": 0.7957747155, "hidden": true}, + {"slug": "gilberts-to-ampere-turns", "name": "Gilberts to Ampere-turns", "category": "magnetism", "type": "standard", "teaser": "Translate the historical gilbert into modern ampere-turns.", "labels": {"in1": "Gilberts", "in2": "Ampere-turns"}, "factor": 1.2566370614}, + {"slug": "weber-to-maxwell", "name": "Weber to Maxwell", "category": "magnetism", "type": "standard", "teaser": "Translate SI magnetic flux into cgs maxwells.", "labels": {"in1": "Weber", "in2": "Maxwell"}, "factor": 100000000.0}, + {"slug": "tesla-to-kilogauss", "name": "Tesla to Kilogauss", "category": "magnetism", "type": "standard", "teaser": "Translate tesla directly to kilogauss for chart comparisons.", "labels": {"in1": "Tesla", "in2": "Kilogauss"}, "factor": 10.0}, + {"slug": "kilogauss-to-tesla", "name": "Kilogauss to Tesla", "category": "magnetism", "type": "standard", "teaser": "Return kilogauss values back into tesla.", "labels": {"in1": "Kilogauss", "in2": "Tesla"}, "factor": 0.1, "hidden": true}, + {"slug": "cubic-meters-per-second-to-liters-per-minute", "name": "Cubic meters per second to Liters per minute", "category": "fluids", "type": "standard", "teaser": "Turn volumetric flow rates into convenient liters/minute values.", "labels": {"in1": "Cubic meters per second", "in2": "Liters per minute"}, "factor": 60000.0}, + {"slug": "kilograms-per-second-to-pounds-per-hour", "name": "Kilograms per second to Pounds per hour", "category": "weight", "type": "standard", "teaser": "Convert mass flow from the SI kilogram scale to imperial pounds per hour.", "labels": {"in1": "Kilograms per second", "in2": "Pounds per hour"}, "factor": 7936.641761}, + {"slug": "pounds-per-hour-to-kilograms-per-second", "name": "Pounds per hour to Kilograms per second", "category": "weight", "type": "standard", "teaser": "Bring imperial mass flow back into the SI kilogram rate.", "labels": {"in1": "Pounds per hour", "in2": "Kilograms per second"}, "factor": 0.000126577, "hidden": true}, + {"slug": "moles-per-second-to-moles-per-hour", "name": "Moles per second to Moles per hour", "category": "other", "type": "standard", "teaser": "Translate molar flow between seconds and hours.", "labels": {"in1": "Moles per second", "in2": "Moles per hour"}, "factor": 3600.0}, + {"slug": "moles-per-hour-to-moles-per-second", "name": "Moles per hour to Moles per second", "category": "other", "type": "standard", "teaser": "Return molar flow rates back to per-second units.", "labels": {"in1": "Moles per hour", "in2": "Moles per second"}, "factor": 0.0002777778, "hidden": true}, + {"slug": "kilograms-per-second-per-square-meter-to-grams-per-second-per-square-centimeter", "name": "Kilograms per second per square meter to Grams per second per square centimeter", "category": "other", "type": "standard", "teaser": "Express mass flux density using metric subunits.", "labels": {"in1": "Kilograms per second per square meter", "in2": "Grams per second per square centimeter"}, "factor": 0.1, "hidden": true}, + {"slug": "grams-per-second-per-square-centimeter-to-kilograms-per-second-per-square-meter", "name": "Grams per second per square centimeter to Kilograms per second per square meter", "category": "other", "type": "standard", "teaser": "Convert compact mass flux into the SI-friendly base.", "labels": {"in1": "Grams per second per square centimeter", "in2": "Kilograms per second per square meter"}, "factor": 10.0}, + {"slug": "mol-per-cubic-meter-to-mmol-per-liter", "name": "Mol per cubic meter to mmol per liter", "category": "fluids", "type": "standard", "teaser": "Translate molar concentrations across common volume units.", "labels": {"in1": "Mol per cubic meter", "in2": "mmol per liter"}, "hidden": true}, + {"slug": "mmol-per-liter-to-mol-per-cubic-meter", "name": "mmol per liter to mol per cubic meter", "category": "fluids", "type": "standard", "teaser": "Convert molar concentration back into SI cubic meters.", "labels": {"in1": "mmol per liter", "in2": "mol per cubic meter"}}, + {"slug": "percent-by-mass-to-ppm", "name": "Percent by mass to ppm", "category": "other", "type": "standard", "teaser": "Turn mass-percent concentrations into parts-per-million.", "labels": {"in1": "Percent by mass", "in2": "ppm"}, "factor": 10000.0}, + {"slug": "ppm-to-percent-by-mass", "name": "ppm to Percent by mass", "category": "other", "type": "standard", "teaser": "Return ppm values to mass-percent.", "labels": {"in1": "ppm", "in2": "Percent by mass"}, "factor": 0.0001, "hidden": true}, + {"slug": "pascal-second-to-poise", "name": "Pascal-second to Poise", "category": "pressure", "type": "standard", "teaser": "Convert SI dynamic viscosity into CGS poise.", "labels": {"in1": "Pascal-second", "in2": "Poise"}, "factor": 10.0}, + {"slug": "poise-to-pascal-second", "name": "Poise to Pascal-second", "category": "pressure", "type": "standard", "teaser": "Bring poise measurements back into pascal-seconds.", "labels": {"in1": "Poise", "in2": "Pascal-second"}, "factor": 0.1, "hidden": true}, + {"slug": "pascal-second-to-centipoise", "name": "Pascal-second to Centipoise", "category": "pressure", "type": "standard", "teaser": "Express pascal-seconds as centipoise for lab viscosity.", "labels": {"in1": "Pascal-second", "in2": "Centipoise"}, "factor": 100.0}, + {"slug": "centipoise-to-pascal-second", "name": "Centipoise to Pascal-second", "category": "pressure", "type": "standard", "teaser": "Convert centipoise into pascal-seconds.", "labels": {"in1": "Centipoise", "in2": "Pascal-second"}, "factor": 0.01, "hidden": true}, + {"slug": "square-meter-per-second-to-centistokes", "name": "Square meter per second to Centistokes", "category": "other", "type": "standard", "teaser": "Translate kinematic viscosity into centistokes.", "labels": {"in1": "Square meter per second", "in2": "Centistokes"}, "factor": 100.0}, + {"slug": "centistokes-to-square-meter-per-second", "name": "Centistokes to Square meter per second", "category": "other", "type": "standard", "teaser": "Return centistokes back to base square meters per second.", "labels": {"in1": "Centistokes", "in2": "Square meter per second"}, "factor": 0.01, "hidden": true}, + {"slug": "newton-per-meter-to-dyne-per-centimeter", "name": "Newton per meter to Dyne per centimeter", "category": "force", "type": "standard", "teaser": "Express surface tension on the CGS scale.", "labels": {"in1": "Newton per meter", "in2": "Dyne per centimeter"}, "factor": 1000.0}, + {"slug": "dyne-per-centimeter-to-newton-per-meter", "name": "Dyne per centimeter to Newton per meter", "category": "force", "type": "standard", "teaser": "Convert surface tension back into SI.", "labels": {"in1": "Dyne per centimeter", "in2": "Newton per meter"}, "factor": 0.001, "hidden": true}, + {"slug": "henry-per-meter-to-tesla-meter-per-ampere", "name": "Henry per meter to Tesla-meter per ampere", "category": "magnetism", "type": "standard", "teaser": "Equate magnetic permeability units across SI conventions.", "labels": {"in1": "Henry per meter", "in2": "Tesla-meter per ampere"}}, + {"slug": "tesla-meter-per-ampere-to-henry-per-meter", "name": "Tesla-meter per ampere to Henry per meter", "category": "magnetism", "type": "standard", "teaser": "Return permeability back to henry per meter.", "labels": {"in1": "Tesla-meter per ampere", "in2": "Henry per meter"}, "hidden": true}, {"slug": "awg-to-circular-mils", "name": "AWG to Circular mils", "category": "electrical", "type": "awg", "teaser": "Convert American Wire Gauge sizes into circular mil areas.", "labels": {"in1": "AWG", "in2": "Circular mils"}}, {"slug": "awg-to-millimeters-diameter", "name": "AWG to Millimeters (diameter)", "category": "electrical", "type": "awg", "teaser": "Express AWG gauge as a diameter in millimeters.", "labels": {"in1": "AWG", "in2": "Millimeters (diameter)"}}, {"slug": "awg-to-square-millimeters-cross-section", "name": "AWG to Square millimeters (cross-section)", "category": "electrical", "type": "awg", "teaser": "Convert AWG sizes into cross-sectional area in mm\u00b2.", "labels": {"in1": "AWG", "in2": "Square millimeters (cross-section)"}}, {"slug": "board-feet-energy-equiv-to-btu", "name": "Board feet (energy equiv.) to BTU", "category": "energy", "type": "standard", "teaser": "Convert the energy equivalent of a board foot of lumber into BTUs.", "labels": {"in1": "Board feet (energy equiv.)", "in2": "BTU"}, "factor": 14000.0}, {"slug": "brinell-to-rockwell-c", "name": "Brinell to Rockwell C", "category": "other", "type": "brinell-rockwell", "teaser": "Approximate Rockwell C hardness from Brinell hardness numbers.", "labels": {"in1": "Brinell", "in2": "Rockwell C"}}, + {"slug": "cloves-to-kilograms", "name": "Cloves to Kilograms", "category": "weight", "type": "standard", "teaser": "Convert traditional clove mass into kilograms.", "labels": {"in1": "Cloves", "in2": "Kilograms"}, "factor": 3.62873896}, + {"slug": "em-to-pixels", "name": "Em to Pixels", "category": "other", "type": "standard", "teaser": "Convert CSS em units to pixels assuming a 16px base size.", "labels": {"in1": "Em", "in2": "Pixels"}, "factor": 16.0}, + {"slug": "ev-to-lux", "name": "EV (exposure value) to Lux", "category": "light", "type": "ev-lux", "teaser": "Estimate scene illuminance at ISO 100.", "labels": {"in1": "EV (exposure value)", "in2": "Lux"}}, + {"slug": "lux-to-ev", "name": "Lux to EV", "category": "light", "type": "ev-lux", "teaser": "Convert lux readings to exposure value at ISO 100.", "labels": {"in1": "Lux", "in2": "EV"}, "hidden": true}, + {"slug": "f-stops-to-t-stops", "name": "f-stops to T-stops", "category": "other", "type": "standard", "teaser": "Treat f-number as t-stop under ideal transmission.", "labels": {"in1": "f-stops", "in2": "T-stops"}}, + {"slug": "focal-length-to-angle-of-view", "name": "Focal length to Angle of view", "category": "other", "type": "aov", "teaser": "Approximate horizontal angle on 35mm full-frame (36mm width).", "labels": {"in1": "Focal length", "in2": "Angle of view"}}, + {"slug": "millimeters-to-awg", "name": "Millimeters to AWG", "category": "electrical", "type": "awg", "teaser": "Convert conductor diameter in millimeters to AWG gauge.", "labels": {"in1": "Millimeters", "in2": "AWG"}}, ]; diff --git a/hdyc-svelte/src/lib/engine.ts b/hdyc-svelte/src/lib/engine.ts index c96e3c6..4d2b427 100644 --- a/hdyc-svelte/src/lib/engine.ts +++ b/hdyc-svelte/src/lib/engine.ts @@ -199,30 +199,71 @@ export function solve( const slug = calc.slug; const formatAwg = (g: number) => isFinite(g) ? fmt(g) : ''; + const awgIsInput = calc.labels.in1.toLowerCase().includes('awg'); + const isCircular = slug.includes('circular-mils'); + const isArea = slug.includes('square-millimeters'); - if (slug.includes('circular-mils')) { - if (source === 1) { - out.val2 = !isNaN(v1) ? fmt(awgToCircularMils(v1)) : ''; + if (isCircular) { + if (awgIsInput) { + if (source === 1) out.val2 = !isNaN(v1) ? fmt(awgToCircularMils(v1)) : ''; + else out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(circularMilsToAwg(v2)) : ''; } else { - out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(circularMilsToAwg(v2)) : ''; + if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? formatAwg(circularMilsToAwg(v1)) : ''; + else out.val1 = !isNaN(v2) ? fmt(awgToCircularMils(v2)) : ''; } - } else if (slug.includes('square-millimeters')) { - if (source === 1) { - out.val2 = !isNaN(v1) ? fmt(awgToAreaMm2(v1)) : ''; + } else if (isArea) { + if (awgIsInput) { + if (source === 1) out.val2 = !isNaN(v1) ? fmt(awgToAreaMm2(v1)) : ''; + else out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(areaMm2ToAwg(v2)) : ''; } else { - out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(areaMm2ToAwg(v2)) : ''; + if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? formatAwg(areaMm2ToAwg(v1)) : ''; + else out.val1 = !isNaN(v2) ? fmt(awgToAreaMm2(v2)) : ''; } } else { // diameter in millimeters - if (source === 1) { - out.val2 = !isNaN(v1) ? fmt(awgToDiameterMm(v1)) : ''; + if (awgIsInput) { + if (source === 1) out.val2 = !isNaN(v1) ? fmt(awgToDiameterMm(v1)) : ''; + else out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(diameterMmToAwg(v2)) : ''; } else { - out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(diameterMmToAwg(v2)) : ''; + if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? formatAwg(diameterMmToAwg(v1)) : ''; + else out.val1 = !isNaN(v2) ? fmt(awgToDiameterMm(v2)) : ''; } } break; } + case 'ev-lux': { + const isEvFirst = calc.labels.in1.toLowerCase().includes('ev'); + const toLux = (ev: number) => 2.5 * Math.pow(2, ev); + const toEv = (lux: number) => lux > 0 ? Math.log(lux / 2.5) / Math.log(2) : NaN; + if (isEvFirst) { + if (source === 1) out.val2 = !isNaN(v1) ? fmt(toLux(v1)) : ''; + else out.val1 = (!isNaN(v2) && v2 > 0) ? fmt(toEv(v2)) : ''; + } else { + if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? fmt(toEv(v1)) : ''; + else out.val1 = !isNaN(v2) ? fmt(toLux(v2)) : ''; + } + break; + } + + case 'aov': { + const sensorWidth = 36; // mm, full-frame horizontal + const isFocalFirst = calc.labels.in1.toLowerCase().includes('focal'); + const toAov = (f: number) => f > 0 ? (2 * Math.atan(sensorWidth / (2 * f)) * 180 / Math.PI) : NaN; + const toFocal = (angle: number) => { + const radians = angle * Math.PI / 180; + return Math.tan(radians / 2) !== 0 ? sensorWidth / (2 * Math.tan(radians / 2)) : NaN; + }; + if (isFocalFirst) { + if (source === 1) out.val2 = (!isNaN(v1) && v1 !== 0) ? fmt(toAov(v1)) : ''; + else out.val1 = (!isNaN(v2) && v2 !== 0) ? fmt(toFocal(v2)) : ''; + } else { + if (source === 1) out.val2 = (!isNaN(v1) && v1 !== 0) ? fmt(toFocal(v1)) : ''; + else out.val1 = (!isNaN(v2) && v2 !== 0) ? fmt(toAov(v2)) : ''; + } + break; + } + case 'brinell-rockwell': { // Approximate correlation for steels: // BHN = (1520000 - 4500 * HRC) / (100 - HRC)^2 diff --git a/migrate.py b/migrate.py index 36eeb76..928ec8d 100644 --- a/migrate.py +++ b/migrate.py @@ -120,7 +120,11 @@ def process(): offset_val = "0" # Special-case calculator families that require custom math beyond simple factors. - if 'awg' in slug: + if 'ev-to-lux' in slug or 'lux-to-ev' in slug: + c_type = 'ev-lux' + elif 'focal-length-to-angle-of-view' in slug: + c_type = 'aov' + elif 'awg' in slug: c_type = 'awg' elif 'brinell-to-rockwell-c' == slug or 'rockwell-c-to-brinell' == slug: c_type = 'brinell-rockwell' @@ -301,7 +305,7 @@ def process(): # Ensure types are right # write to TS out = """// THIS FILE IS AUTO-GENERATED BY migrate.py -export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell'; +export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell' | 'ev-lux' | 'aov'; export interface CalculatorDef { slug: string;