Center of mass calculator
Find where a set of point masses balances: masses of 2, 4 and 3 at (0, 0), (6, 0) and (0, 6) balance at (2.6666666667, 2), with a total mass of 9. It works on a line, a plane or in space. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
The center of mass of a system of point masses is the single point where the whole system would balance — the mass-weighted average of the positions. This capability takes a list of point masses with coordinates (x required, y and z optional) and returns the exact coordinates of the center, along with the point count and total mass. It works in one dimension for beads on a wire, in two dimensions for masses on a plate, and in three dimensions for bodies in space, all through the same formula: sum each mass times its position, divide by the total mass.
What the center of mass is and why it matters
In classical mechanics the center of mass is the point that moves as if all the mass of a system were concentrated there and all external forces acted on it. Throw a wrench across a room and its center of mass traces a clean parabola no matter how the wrench tumbles. The same point is where a mobile hangs level, where a rocket's equations of motion are written, and where a game engine places the pivot of a rigid body.
For a set of discrete point masses the definition is a simple weighted average: multiply each mass by its position, add the products, and divide by the total mass. Each coordinate axis is computed independently, so the x coordinate of the center depends only on the masses and their x positions, and likewise for y and z. This calculator answers exactly that question for 1D, 2D and 3D systems.
Students checking homework, teachers building exercise generators, and developers prototyping physics code all search for a center of mass calculator when they need a trustworthy barycenter without wiring up a library. Negative masses are accepted mathematically, which is occasionally useful for modeling holes or counterweights, as long as the total mass is not zero.
Input contract, validation, and the formula used
Each object must carry mass and x; the fields y and z are optional and default to zero. Numbers and numeric strings are both accepted, and every value must be finite. At least one point is required, and the list is capped at ten thousand points, far beyond any classroom or scripting workload.
The engine then applies the standard formula: the total mass M is the sum of all masses, and each coordinate of the center is the sum of mass times position divided by M. If a dimension is absent from every point it is simply omitted from the response, so a purely 1D problem returns only x, while any point with a y or z promotes the output to 2D or 3D.
Results are rounded to a stable number of decimal places so floating-point noise does not break equality checks across JavaScript engines.
What you can do with it
Physics homework and grading
Students and teachers verify the center of mass of systems of point masses in 1D, 2D or 3D without a local CAS or spreadsheet.
Balance and pivot placement
Find the balance point of weighted objects on a beam, plate or mobile so a design hangs level the first time.
FAQ
What formula does the center of mass calculator use?
The mass-weighted average per axis: each coordinate of the center is the sum of mass times position divided by the total mass, computed independently for x, y and z.
Does it work in 2D and 3D?
Yes. Only x is required; add y and/or z to any point and the response includes the center for those dimensions too.
Is the center of mass calculator free?
The browser tool runs free on your device.
Can a mass be negative?
Yes. Negative masses are accepted, which helps to model holes or counterweights, as long as the total mass does not come out as zero, because a zero total has no center.
How is the center of mass different from the plain average of the points?
Each position is weighted by its mass, so heavier points pull the center toward them. In the example the plain average of the x values is 2, but the center of mass sits at 2.6666666667 because the heaviest mass, 4, lies at x 6.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/math/center-of-mass \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"points":[{"mass":2,"x":0,"y":0},{"mass":4,"x":6,"y":0},{"mass":3,"x":0,"y":6}]}'const res = await fetch("https://api.kit.forhosting.com/math/center-of-mass", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"points": [
{
"mass": 2,
"x": 0,
"y": 0
},
{
"mass": 4,
"x": 6,
"y": 0
},
{
"mass": 3,
"x": 0,
"y": 6
}
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/center-of-mass",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"points": [
{
"mass": 2,
"x": 0,
"y": 0
},
{
"mass": 4,
"x": 6,
"y": 0
},
{
"mass": 3,
"x": 0,
"y": 6
}
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/center-of-mass", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"points":[{"mass":2,"x":0,"y":0},{"mass":4,"x":6,"y":0},{"mass":3,"x":0,"y":6}]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"points":[{"mass":2,"x":0,"y":0},{"mass":4,"x":6,"y":0},{"mass":3,"x":0,"y":6}]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/center-of-mass", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"points": [
{
"mass": 2,
"x": 0,
"y": 0
},
{
"mass": 4,
"x": 6,
"y": 0
},
{
"mass": 3,
"x": 0,
"y": 6
}
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.center_of_mass",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_points | 10000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
A zero total mass makes the center undefined, and the request is rejected with a clear validation error. The browser tool runs free on your device; the prepaid API charges $0.002 per successful request.
Input contract, validation, and the formula used
Send a JSON object whose required field points is an array of objects, one per point mass. Aliases are accepted: the array may be called masses, bodies or particles, and a mass may be written as m, weight or w. The one mathematically undefined case is a total mass of exactly zero — for example two equal positive and negative masses — because division by zero mass has no meaning; that input fails with invalid_input and a clear message, and validation failures are never charged. There is no physics library and no external service in the path — only arithmetic on a Worker isolate, the same code that powers the free in-browser tool.
API usage, pricing, and practical workflows
Use the free browser center of mass calculator when you want an immediate answer while solving a physics problem, balancing a two-mass seesaw, or placing the pivot of a composite object, without installing anything. Because identical inputs always produce identical outputs, teams on different continents can assert the same expected values in their continuous integration without any shared state. The capability stores nothing: the point list is processed in memory and discarded, and only the computed center is returned. Use the prepaid API when a homework generator, a simulation pipeline, a robotics script or a test suite needs the same deterministic contract under your KIT balance at $0.002 per successful request; requests that fail validation consume nothing. The response is compact structured JSON: count echoes the number of points, total_mass reports the summed mass, and x, y, z give the center coordinates for the dimensions present in the input. Pair this endpoint with moment of inertia or force calculators when the next step is dynamics rather than statics.
Integration use cases
Deterministic fixtures for physics code
Pin known-answer center of mass results in CI for a game engine or simulation instead of reimplementing the weighted average everywhere.
Technical questions
How do I compute the center of mass of point masses?
Send JSON with points as an array of {mass, x, y?, z?} objects. The response returns total_mass and the center coordinates x (plus y and z when present in the input).
What happens if the total mass is zero?
The request fails with invalid_input because the center of mass is undefined for a zero-mass system. Validation failures are not charged.