Visualizer for the moment field of a single force — coursework for Mecânica I
(Escola Politécnica da USP). Given a force F applied at a point P, the
program draws M(O) = (P − O) ∧ F over sampled poles O and demonstrates that
the field is axisymmetric about the line of action of F.
This is the Python reference implementation: an interactive CLI that produces a static PDF report (perspective views plus the two proof sections) and a numerical verification of the axisymmetry.
python3 -m venv .venv
.venv/bin/pip install -r requirements.txtInteractive (asks for P and F in the shell):
.venv/bin/python -m momentfieldNon-interactive:
.venv/bin/python -m momentfield --ponto "1 0 2" --forca "2 1 -1.5" --saida campo_de_momentos.pdfRun .venv/bin/python -m momentfield --help for the sampling options
(number of planes, spacing, angular step, radii, moment drawing scale) and the
optional JSON export of the samples.
The output PDF contains:
- a title page with the input data, the sampling layout, the color legend and the numerical verification results;
- perspective views of the full field from several observer positions;
- the section normal to the line of action (single plane of poles — the pinwheel invariant under 60° rotations);
- the section containing the line of action (moments normal to the page, magnitude linear in the distance to the axis), plus a slightly tilted view of the same data to make the out-of-page vectors visible.
.venv/bin/python -m pytest tests/The tests are numerical assertions to machine precision: M · u = 0,
|M| = |F| · dist(O, axis), invariance under axial translation, rotational
equivariance, sampling layout, and exact round-trip of the JSON contract.