d4t_formulas/assets/formulas/formulas.d4rt
Álvaro González 9f2c569279 Big merge. Watch out!
Merge branch 'feature/more-copilot-formulas' of ssh://codeberg.org/alvarogonzalezsotillo/d4rt_formulas into feature/more-copilot-formulas
2026-02-27 08:40:38 +01:00

447 lines
11 KiB
Text

[
// Projectile Motion Range
{
"name": "Projectile Range",
"description": r"""
Calculates horizontal distance of projectile motion
$$R = \frac{v^2 \sin(2\theta)}{g}$$
Where:
- $v$: Initial velocity
- $\theta$: Launch angle
- $g$: Gravitational acceleration
![Projectile Motion](https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Projectile_motion_diagram.png/800px-Projectile_motion_diagram.png)""",
"input": [
{"name": "v", "unit": "meters per second"},
{"name": "a", "unit": "degree"}
],
"output": {"name": "R", "unit": "meter"},
"d4rtCode": """
var radians = a * (pi / 180);
R = (pow(v, 2) * sin(2 * radians)) / 9.80665;
""",
"tags": ["physics", "kinematics", "projectile"]
},
// Newton's Second Law
{
"name": "Newton's Second Law",
"description": r"""
Force equals mass times acceleration
$$F = m \cdot a$$
Where:
- $m$: Mass of object ($\mathrm{kg}$)
- $a$: Acceleration ($\mathrm{m/s^2}$)
![Newton's Second Law](https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Newtonslawsofmotion.jpg/800px-Newtonslawsofmotion.jpg)""",
"input": [
{"name": "m", "unit": "kilogram"},
{"name": "a", "unit": "meters per square second"}
],
"output": {"name": "F", "unit": "newton"},
"d4rtCode": "F = m * a;",
"tags": ["physics", "mechanics", "newton"]
},
// Centripetal Force
{
"name": "Centripetal Force",
"description": r"""
Force required to keep an object moving in circular motion
$$F = \frac{mv^2}{r}$$
Where:
- $F$: Centripetal force (Newtons)
- $m$: Mass of object (kilograms)
- $v$: Velocity (m/s)
- $r$: Radius of circular path (meters)
This force acts toward the center of the circle.""",
"input": [
{"name": "m", "unit": "kilogram"},
{"name": "v", "unit": "meters per second"},
{"name": "r", "unit": "meter"}
],
"output": {"name": "F", "unit": "newton"},
"d4rtCode": "F = (m * pow(v, 2)) / r;",
"tags": ["physics", "circular motion", "centripetal"]
},
// Wave Equation
{
"name": "Wave Equation",
"description": r"""
Relationship between wave speed, frequency, and wavelength
$$v = f\lambda$$
Where:
- $v$: Wave speed (m/s)
- $f$: Frequency (Hertz)
- $\lambda$: Wavelength (meters)
This applies to all types of waves including sound and light.""",
"input": [
{"name": "f", "unit": "hertz"},
{"name": "lambda", "unit": "meter"}
],
"output": {"name": "v", "unit": "meters per second"},
"d4rtCode": "v = f * lambda;",
"tags": ["physics", "waves", "frequency"]
},
// Pythagorean Theorem
{
"name": "Pythagorean Theorem",
"description": r"""
Fundamental relation in Euclidean geometry among the three sides of a right triangle
$$a^2 + b^2 = c^2$$
Where:
- $a$, $b$: Legs of the right triangle
- $c$: Hypotenuse of the right triangle
The square of the hypotenuse is equal to the sum of squares of the other two sides.""",
"input": [
{"name": "a", "unit": "meter"},
{"name": "b", "unit": "meter"}
],
"output": {"name": "c", "unit": "meter"},
"d4rtCode": "c = sqrt(pow(a, 2) + pow(b, 2));",
"tags": ["trigonometry", "geometry", "pythagorean"]
},
// Sine Rule
{
"name": "Sine Rule",
"description": r"""
Relationship between the sides and angles of any triangle
$$\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}$$
Where:
- $a$, $b$, $c$: Sides of the triangle
- $A$, $B$, $C$: Angles opposite to sides $a$, $b$, $c$ respectively
This rule is useful for solving triangles when certain combinations of angles and sides are known.""",
"input": [
{"name": "a", "unit": "meter"},
{"name": "A", "unit": "degree"},
{"name": "B", "unit": "degree"}
],
"output": {"name": "b", "unit": "meter"},
"d4rtCode": """
var angleARad = A * (pi / 180);
var angleBRad = B * (pi / 180);
b = (a * sin(angleBRad)) / sin(angleARad);
""",
"tags": ["trigonometry", "triangle", "sine"]
},
// Cosine Rule
{
"name": "Cosine Rule",
"description": r"""
Generalization of the Pythagorean theorem for any triangle
$$c^2 = a^2 + b^2 - 2ab\cos(C)$$
Where:
- $a$, $b$, $c$: Sides of the triangle
- $C$: Angle opposite to side $c$
This rule relates all three sides of a triangle to one of its angles.""",
"input": [
{"name": "a", "unit": "meter"},
{"name": "b", "unit": "meter"},
{"name": "C", "unit": "degree"}
],
"output": {"name": "c", "unit": "meter"},
"d4rtCode": """
var angleCRad = C * (pi / 180);
c = sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(angleCRad));
""",
"tags": ["trigonometry", "triangle", "cosine"]
},
// Trigonometric Identity
{
"name": "Trigonometric Identity",
"description": r"""
Fundamental Pythagorean identity in trigonometry
$$\sin^2(\theta) + \cos^2(\theta) = 1$$
Where:
- $\theta$: Any angle in radians or degrees
This identity is derived from the Pythagorean theorem applied to the unit circle.""",
"input": [
{"name": "theta", "unit": "degree"}
],
"output": {"name": "result", "unit": "scalar"},
"d4rtCode": """
var thetaRad = theta * (pi / 180);
result = pow(sin(thetaRad), 2) + pow(cos(thetaRad), 2);
""",
"tags": ["trigonometry", "identity", "sine", "cosine"]
},
// Gravitational Potential Energy
{
"name": "Gravitational Potential Energy",
"description": r"""
Energy possessed by an object due to its position in a gravitational field
$$PE = mgh$$
Where:
- $m$: Mass of object (kilograms)
- $g$: Gravitational acceleration ($9.81\ \mathrm{m/s^2}$ on Earth)
- $h$: Height above reference point (meters)
This energy increases with height and can be converted to kinetic energy.""",
"input": [
{"name": "m", "unit": "kilogram"},
{"name": "h", "unit": "meter"},
{"name": "g", "unit": "meters per square second"}
],
"output": {"name": "PE", "unit": "joule"},
"d4rtCode": "PE = m * g * h;",
"tags": ["physics", "energy", "mechanics", "gravity"]
},
// Linear Momentum
{
"name": "Linear Momentum",
"description": r"""
Quantity of motion possessed by a moving object
$$p = mv$$
Where:
- $p$: Momentum ($\mathrm{kg \cdot m/s}$)
- $m$: Mass (kilograms)
- $v$: Velocity (m/s)
Momentum is conserved in isolated systems.""",
"input": [
{"name": "m", "unit": "kilogram"},
{"name": "v", "unit": "meters per second"}
],
"output": {"name": "p", "unit": "kilogram meter per second"},
"d4rtCode": "p = m * v;",
"tags": ["physics", "mechanics", "momentum"]
},
// Volume of Sphere
{
"name": "Volume of Sphere",
"description": r"""
Volume enclosed by a sphere
$$V = \frac{4}{3}\pi r^3$$
Where:
- $V$: Volume (cubic meters)
- $r$: Radius (meters)
- $\pi$: Pi ($\approx 3.14159$)
The volume is proportional to the cube of the radius.""",
"input": [
{"name": "r", "unit": "meter"}
],
"output": {"name": "V", "unit": "cubic meter"},
"d4rtCode": "V = (4.0/3.0) * pi * pow(r, 3);",
"tags": ["geometry", "sphere", "volume"]
},
// Surface Area of Sphere
{
"name": "Surface Area of Sphere",
"description": r"""
Total surface area of a sphere
$$A = 4\pi r^2$$
Where:
- $A$: Surface area (square meters)
- $r$: Radius (meters)
- $\pi$: Pi ($\approx 3.14159$)
The surface area is four times the area of a circle with the same radius.""",
"input": [
{"name": "r", "unit": "meter"}
],
"output": {"name": "A", "unit": "square meter"},
"d4rtCode": "A = 4 * pi * pow(r, 2);",
"tags": ["geometry", "sphere", "surface area"]
},
// Volume of Cylinder
{
"name": "Volume of Cylinder",
"description": r"""
Volume enclosed by a cylinder
$$V = \pi r^2 h$$
Where:
- $V$: Volume (cubic meters)
- $r$: Radius of base (meters)
- $h$: Height (meters)
- $\pi$: Pi ($\approx 3.14159$)
The volume is the area of the base times the height.""",
"input": [
{"name": "r", "unit": "meter"},
{"name": "h", "unit": "meter"}
],
"output": {"name": "V", "unit": "cubic meter"},
"d4rtCode": "V = pi * pow(r, 2) * h;",
"tags": ["geometry", "cylinder", "volume"]
},
// Surface Area of Cylinder
{
"name": "Surface Area of Cylinder",
"description": r"""
Total surface area of a cylinder (including top and bottom)
$$A = 2\pi r(r + h)$$
Where:
- $A$: Total surface area (square meters)
- $r$: Radius of base (meters)
- $h$: Height (meters)
- $\pi$: Pi ($\approx 3.14159$)
This includes the lateral surface plus the two circular ends.""",
"input": [
{"name": "r", "unit": "meter"},
{"name": "h", "unit": "meter"}
],
"output": {"name": "A", "unit": "square meter"},
"d4rtCode": "A = 2 * pi * r * (r + h);",
"tags": ["geometry", "cylinder", "surface area"]
},
// Volume of Cone
{
"name": "Volume of Cone",
"description": r"""
Volume enclosed by a cone
$$V = \frac{1}{3}\pi r^2 h$$
Where:
- $V$: Volume (cubic meters)
- $r$: Radius of base (meters)
- $h$: Height (meters)
- $\pi$: Pi ($\approx 3.14159$)
The volume is one-third the volume of a cylinder with the same base and height.""",
"input": [
{"name": "r", "unit": "meter"},
{"name": "h", "unit": "meter"}
],
"output": {"name": "V", "unit": "cubic meter"},
"d4rtCode": "V = (1.0/3.0) * pi * pow(r, 2) * h;",
"tags": ["geometry", "cone", "volume"]
},
// Volume of Cube
{
"name": "Volume of Cube",
"description": r"""
Volume enclosed by a cube
$$V = s^3$$
Where:
- $V$: Volume (cubic meters)
- $s$: Side length (meters)
The volume is the cube of the side length.""",
"input": [
{"name": "s", "unit": "meter"}
],
"output": {"name": "V", "unit": "cubic meter"},
"d4rtCode": "V = pow(s, 3);",
"tags": ["geometry", "cube", "volume"]
},
// Surface Area of Cube
{
"name": "Surface Area of Cube",
"description": r"""
Total surface area of a cube
$$A = 6s^2$$
Where:
- $A$: Total surface area (square meters)
- $s$: Side length (meters)
The surface area is six times the area of one face.""",
"input": [
{"name": "s", "unit": "meter"}
],
"output": {"name": "A", "unit": "square meter"},
"d4rtCode": "A = 6 * pow(s, 2);",
"tags": ["geometry", "cube", "surface area"]
},
// Perimeter of Rectangle
{
"name": "Perimeter of Rectangle",
"description": r"""
Total distance around a rectangle
$$P = 2(l + w)$$
Where:
- $P$: Perimeter (meters)
- $l$: Length (meters)
- $w$: Width (meters)
The perimeter is twice the sum of length and width.""",
"input": [
{"name": "l", "unit": "meter"},
{"name": "w", "unit": "meter"}
],
"output": {"name": "P", "unit": "meter"},
"d4rtCode": "P = 2 * (l + w);",
"tags": ["geometry", "rectangle", "perimeter"]
},
// Perimeter of Triangle
{
"name": "Perimeter of Triangle",
"description": r"""
Total distance around a triangle
$$P = a + b + c$$
Where:
- $P$: Perimeter (meters)
- $a, b, c$: Side lengths (meters)
The perimeter is the sum of all three sides.""",
"input": [
{"name": "a", "unit": "meter"},
{"name": "b", "unit": "meter"},
{"name": "c", "unit": "meter"}
],
"output": {"name": "P", "unit": "meter"},
"d4rtCode": "P = a + b + c;",
"tags": ["geometry", "triangle", "perimeter"]
}
]