GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Alphka/Coulombs-Law: A Next.js website that calculates the force between two stationary electric charges with Coulomb's law, or a missing charge or distance, showing every step. Available in English and Brazilian Portuguese.

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
.agents/skills
.agents/skills
 
 
.claude
.claude
 
 
.github
.github
 
 
.vscode
.vscode
 
 
messages
messages
 
 
src
src
 
 
.cspell.json
.cspell.json
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.mcp.json
.mcp.json
 
 
.ncurc.json
.ncurc.json
 
 
.npmrc
.npmrc
 
 
.vercelignore
.vercelignore
 
 
AGENTS.md
AGENTS.md
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
README.pt-BR.md
README.pt-BR.md
 
 
eslint.config.ts
eslint.config.ts
 
 
jest.config.ts
jest.config.ts
 
 
jest.setup.ts
jest.setup.ts
 
 
next.config.ts
next.config.ts
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 
postcss.config.mjs
postcss.config.mjs
 
 
skills-lock.json
skills-lock.json
 
 
tsconfig.json
tsconfig.json
 
 
vercel.json
vercel.json
 
 

Repository files navigation

Coulomb's Law

English | Português (Brasil)

A website that calculates the force, charge or distance between two stationary electric charges
Every step of the calculation is shown
Live site

Build License: ISC TypeScript Next.js Tailwind CSS

About

The page has three calculators. Given Coulomb's constant and any two of the other three quantities, you can find the missing one:

  • Force from the two charges and the distance between them.
  • Charge (the first one) from the force, the second charge and the distance.
  • Distance from the force and the two charges.

Each result is shown as a sequence of algebraic steps, so you can follow how the value was obtained. The interface is available in English and in Brazilian Portuguese.

Screenshot of the distance calculator on desktop Screenshot of the charge calculator on mobile, in Portuguese

Formula and units

The app implements Coulomb's law for two point charges:

$$F = k \cdot \frac{|q_1| \cdot |q_2|}{d^2}$$

Symbol Meaning Unit
F Electrostatic force newton (N)
k Coulomb's constant N·m²/C²
q₁, q₂ Electric charges coulomb (C)
d Distance between the charges meter (m)

Rearranged by the app, as implemented in src/app/helpers/calculate.ts:

  • Charge: q₁ = F · d² / (k · |q₂|)
  • Distance: d = √(k · |q₁| · |q₂| / F)

Note

Coulomb's constant is entered as a coefficient of 10⁹ N·m²/C² and must be between 8.9 and 9 (default 9). The list of suggestions offers 8.998, 8.99, 8.9 and 9.

Charges are used as magnitudes (absolute values), so the force is the magnitude of the force, not its direction (attractive or repulsive).

Input rules

  • Numbers may use a decimal point or a comma, and scientific notation, such as 3, .5, 0,5 or 1.6e-19. The exponent must be between -1000 and 1000.
  • The distance must be greater than zero.
  • Charge calculator: the force cannot be negative and the second charge cannot be zero.
  • Distance calculator: the force must be greater than zero.
  • An invalid field is marked, focused and named in the message.

Features

  • Three calculators in an accessible tabs pattern (the arrow keys, Home and End switch the tab).
  • Exact arithmetic with fraction.js, so there is no floating-point noise such as 12.250000000000002. Values are shown with 12 significant digits.
  • Steps written in native MathML, announced to screen readers. No math library is bundled.
  • English and Brazilian Portuguese (next-intl), with the decimal separator of each language.
  • Enter moves to the next field and submits on the last one.
  • Responsive, dark-only layout styled with Tailwind CSS classes.

Note

The page needs JavaScript enabled.

Tech stack

  • Next.js 16 (App Router) and React 19
  • TypeScript
  • Tailwind CSS v4
  • next-intl for the translations
  • fraction.js for the exact arithmetic
  • Jest and Testing Library for the tests
  • ESLint and cspell for the code style and the spelling
  • pnpm as the package manager

Requirements

  • Node.js 22.22.2 or later. The CI workflow checks the project on the latest release of Node.js 22, 24 and 26.
  • pnpm 11 or 12. The exact version is pinned in the packageManager field of package.json, so it is selected automatically.

Installation

git clone https://github.com/Alphka/Coulombs-Law.git
cd Coulombs-Law
pnpm install

Usage

Start the development server (with hot reload) at http://localhost:3000:

pnpm dev

Build the site and serve the production build:

pnpm build
pnpm start

Scripts

Script Description
pnpm dev Starts the Next.js development server
pnpm build Builds the site for production
pnpm start Serves the production build
pnpm tsc Generates the route and message types, then type-checks the project
pnpm lint Runs ESLint and cspell
pnpm lint:fix Runs ESLint and fixes what it can
pnpm test Runs the tests

Browser support

The supported browsers are listed in the browserslist field of package.json (Chrome and Edge 111+, Firefox 128+, Safari and iOS 16.4+). All of them support MathML.

Deployment

The site is deployed on Vercel. The vercel.json file only sets the Next.js framework, so the project settings in the dashboard do not need to be changed. The security headers are set in next.config.ts.

Project structure

messages/            Translations (en.json is the source of the message types)
src/
├── app/
│   ├── [locale]/    Pages: layout, home and not found
│   ├── components/  Calculator, Tabs, CalculatorForm, NumberField, ConstantField, Result, MathView, LanguageSwitcher
│   ├── entities/    CalculationError
│   ├── helpers/     calculate, calculators (the fields of each calculator), math (MathML nodes and number formatting), parseNumber
│   └── globals.css  Tailwind theme (colors) and the base styles
├── i18n/            next-intl routing, request configuration and navigation
├── testing/         Test helpers
├── typings/         Type declarations (MathML elements, next-intl)
└── proxy.ts         Locale routing
.github/             CI workflow and the screenshots used in this README

Tests

pnpm test runs the unit tests of the calculations, the number formatting and the messages, and the component tests of the calculator. Most expected steps come from the implementation that existed before version 3.0.0, so the steps stay the same, apart from the intended fixes.

License

ISC © 2022 Kayo Souza

About

A Next.js website that calculates the force between two stationary electric charges with Coulomb's law, or a missing charge or distance, showing every step. Available in English and Brazilian Portuguese.

coulomb-law.vercel.app

Topics

coulombcoulombs-laweducationelectricityelectrostatic-potentialelectrostaticsi18nmathmathmlnext-intlnextjsphysicsphysics-calculatorreactsciencetailwindcsstypescriptvercel

Resources

Readme
ISC license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.