From c497633cac8f12ef157cf41ccd7c79f0ba89c252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Gonz=C3=A1lez?= Date: Mon, 15 Sep 2025 22:12:26 +0200 Subject: [PATCH] feat: add angle units and formula documentation --- lib/formulas.d4rt | 38 ++++++++++++++++++++++++++++++++++++++ lib/main.dart | 3 ++- lib/units/angle.d4rt.units | 12 ++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 lib/units/angle.d4rt.units diff --git a/lib/formulas.d4rt b/lib/formulas.d4rt index 70dbd2f..f838795 100644 --- a/lib/formulas.d4rt +++ b/lib/formulas.d4rt @@ -2,6 +2,16 @@ // Free fall distance (vertical) { name: "Free Fall Distance", + description: ''' +Calculates vertical displacement under constant gravity + +`h = ½gt²` + +Where: +- `g` = Gravitational acceleration (9.81 m/s² on Earth) +- `t` = Time in free fall (seconds) + +![Free Fall Diagram](https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Free-fall.svg/1200px-Free-fall.svg.png)''', input: [ {name: "t", magnitude: "s"}, // Time in seconds {name: "g", magnitude: "m/s²"} // Gravitational acceleration @@ -13,6 +23,17 @@ // Newton's Law of Universal Gravitation { name: "Gravitational Force", + description: ''' +Newton's law of universal gravitation + +`F = G(m₁m₂)/r²` + +Where: +- `G` = Gravitational constant (6.674×10⁻¹¹ N·m²/kg²) +- `m₁`, `m₂` = Masses of two objects +- `r` = Distance between centers of masses + +![Gravitation](https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/NewtonsLawOfUniversalGravitation.svg/1200px-NewtonsLawOfUniversalGravitation.svg.png)''', input: [ {name: "m1", magnitude: "kg"}, // Mass 1 {name: "m2", magnitude: "kg"}, // Mass 2 @@ -25,6 +46,16 @@ // Kinetic Energy { name: "Kinetic Energy", + description: ''' +Energy possessed by a moving object + +`KE = ½mv²` + +Where: +- `m` = Mass of object +- `v` = Velocity of object + +![Kinetic Energy](https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Kinetic_energy.svg/1200px-Kinetic_energy.svg.png)''', input: [ {name: "m", magnitude: "kg"}, // Mass {name: "v", magnitude: "m/s"} // Velocity @@ -36,6 +67,13 @@ // Projectile Motion Range { name: "Projectile Range", + description: "Calculates horizontal distance of projectile motion\n\n" + "`R = (v² sin(2θ))/g`\n\n" + "Where:\n" + "- `v` = Initial velocity\n" + "- `θ` = Launch angle\n" + "- `g` = Gravitational acceleration\n\n" + "![Projectile Motion](https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Projectile_motion_diagram.png/800px-Projectile_motion_diagram.png)", input: [ {name: "v", magnitude: "m/s"}, // Initial velocity {name: "θ", magnitude: "deg"} // Launch angle diff --git a/lib/main.dart b/lib/main.dart index f4d0354..6c3dd83 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -33,7 +33,8 @@ Future createTestCorpus() async { "lib/units/pressure.d4rt.units", "lib/units/temperature.d4rt.units", "lib/units/velocity.d4rt.units", - "lib/units/mass.d4rt.units" + "lib/units/mass.d4rt.units", + "lib/units/angle.d4rt.units" ]; for (final resourcePath in resources) { diff --git a/lib/units/angle.d4rt.units b/lib/units/angle.d4rt.units new file mode 100644 index 0000000..8477397 --- /dev/null +++ b/lib/units/angle.d4rt.units @@ -0,0 +1,12 @@ +[ + {"name": "radian", "symbol": "rad", "isBase": true}, + {"name": "degree", "symbol": "°", "baseUnit": "radian", "factor": 0.017453292519943295}, + {"name": "gradian", "symbol": "gon", "baseUnit": "radian", "factor": 0.015707963267948967}, + {"name": "revolution", "symbol": "rev", "baseUnit": "radian", "factor": 6.283185307179586}, + {"name": "arcminute", "symbol": "'", "baseUnit": "radian", "factor": 0.0002908882086657216}, + {"name": "arcsecond", "symbol": "\"", "baseUnit": "radian", "factor": 0.00000484813681109536}, + {"name": "binary degree", "symbol": "brad", "baseUnit": "radian", "factor": 0.02454369260617026}, + {"name": "quadrant", "symbol": "quad", "baseUnit": "radian", "factor": 1.5707963267948966}, + {"name": "sextant", "symbol": "sextant", "baseUnit": "radian", "factor": 1.0471975511965976}, + {"name": "octant", "symbol": "octant", "baseUnit": "radian", "factor": 0.7853981633974483} +]