marksgeometrys
A mathematical library for calculating areas and volumes of geometric figures with unit support, numeric returns, and proper squared/cubed notation.
The project provides 24 ready-to-use geometric classes covering 2D shapes (triangles, polygons, circles), 3D solids (prisms, pyramids, platonic solids), and truncated figures — all with configurable units (mm, cm, m, in, ft, etc.) and clean numeric APIs.
Python | Mathematics | PyPI
Features
- 24 geometric classes — from basic 2D shapes to platonic solids and truncated figures
- Unit-aware calculations — specify mm, cm, m, in, ft, or any custom unit; squared/cubed notation applied automatically
- Clean numeric API —
area()andvolume()returnfloatvalues for direct computation - Formatted output —
area_formatted()andvolume_formatted()return human-readable strings with units (e.g.,25cm²,125m³) - Zero dependencies — pure Python standard library (
mathonly) - PyPI ready — installable via
pip install marksgeometrys - MIT licensed — free for commercial and educational use
Shapes
2D Figures (Area)
| Class | Parameters | Description |
|---|---|---|
Square |
side |
Square area |
Rectangle |
base, height |
Rectangle area |
Triangle |
base, height |
Triangle area |
RegularPolygon |
side, sidesnumber, apothem |
Regular polygon area |
Circle |
radius |
Circle area (πr²) |
Trapezoid |
largebase, smallbase, height |
Trapezoid area |
Rhombus |
largediagonal, smalldiagonal |
Rhombus area |
Parallelogram |
base, height |
Parallelogram area |
3D Figures (Volume + Surface Area)
| Class | Parameters | Description |
|---|---|---|
RegularPolygonPrism |
side, apothem, sidesnumber, height, base |
Prism with regular polygon base |
TriangularPrism |
base, theight, pheight |
Triangular prism |
QuadrangularPrism |
side1, side2, height, base |
Rectangular-based prism |
RectangularPrism |
side1, side2, side3, height |
Rectangular prism (cuboid) |
TrapezoidalPrism |
largebase, smallbase, baseheight, pheight, pbase |
Trapezoidal prism |
Sphere |
radius |
Sphere volume & surface area |
Cube |
side |
Cube volume & surface area |
Cylinder |
radius, height |
Cylinder volume & surface area |
Pyramid |
base, side, sidesnumber, apothem, side1, side2, height |
Pyramid with polygon base |
Cone |
radius, geometry (slant height) |
Cone volume & surface area |
RhomboidalPrism |
largediagonal, smalldiagonal, height, base |
Rhombus-based prism |
Platonic Solids
| Class | Parameters | Description |
|---|---|---|
Tetrahedron |
side, height |
4 faces (triangles) |
Octohedron |
side |
8 faces (triangles) |
Dodecahedron |
side, apothem |
12 faces (pentagons) |
Icosahedron |
side |
20 faces (triangles) |
Truncated Figures
| Class | Parameters | Description |
|---|---|---|
PyramidTrunk |
sbside, sidesnumber, sbapothem, lbside, lbapothem, latlargebase, latsmallbase, latheight, height |
Frustum of a pyramid |
ConeTrunk |
sbradius, geometry, lbradius, height |
Frustum of a cone |
Quick Start
pip install marksgeometrys
from marksgeometrys import Square, Cube, Octohedron, Sphere
# Numeric returns (float) — ideal for calculations
square = Square(side=5)
print(square.area()) # 25.0
cube = Cube(side=3)
print(cube.volume()) # 27.0
print(cube.area()) # 54.0
# Formatted output with units — ideal for display
print(square.area_formatted()) # "25cm²"
print(cube.volume_formatted()) # "27cm³"
# Custom units (mm, m, in, ft, or any string)
square_mm = Square(side=50, unit="mm")
print(square_mm.area_formatted()) # "2500mm²"
sphere_m = Sphere(radius=0.05, unit="m")
print(sphere_m.volume_formatted()) # "0.0005235987755982989m³"
# Platonic solids (Octohedron bug fixed — now returns values for all sides)
octo = Octohedron(side=4)
print(octo.volume()) # 30.17...
print(octo.area()) # 55.43...
print(octo.volume_formatted()) # "30.17cm³"
Installation
# From PyPI
pip install marksgeometrys
# From source
git clone https://github.com/marc1fino/marksgeometrys.git
cd marksgeometrys
pip install -e .
Requires Python 3.8+. Zero external dependencies.
API Reference
Core Methods
Every class provides:
| Method | Returns | Description |
|---|---|---|
area() |
float |
Numeric area value |
area_formatted() |
str |
Area with squared unit (e.g., "25cm²") |
volume() |
float |
Numeric volume value (3D shapes only) |
volume_formatted() |
str |
Volume with cubed unit (e.g., "27cm³") |
Unit Parameter
All classes accept an optional unit parameter (default: "cm"):
Square(side=5) # unit="cm"
Square(side=5, unit="mm") # millimeters
Square(side=0.05, unit="m") # meters
Square(side=2, unit="in") # inches
Square(side=1, unit="ft") # feet
Square(side=10, unit="px") # pixels (or any custom string)
The unit string is used directly in formatted output — squared for area (unit²), cubed for volume (unit³).
Examples
Basic 2D Calculations
from marksgeometrys import Triangle, Circle, RegularPolygon, Rhombus
triangle = Triangle(base=10, height=6)
print(f"Area: {triangle.area()}") # 30.0
print(f"Display: {triangle.area_formatted()}") # "30.0cm²"
circle = Circle(radius=7, unit="m")
print(f"Area: {circle.area():.2f} m²") # 153.94 m²
rhombus = Rhombus(largediagonal=12, smalldiagonal=8, unit="in")
print(rhombus.area_formatted()) # "48.0in²"
3D Volumes and Surface Areas
from marksgeometrys import Cylinder, Cone, Pyramid, RectangularPrism
cylinder = Cylinder(radius=3, height=10)
print(f"Volume: {cylinder.volume():.2f}") # 282.74
print(f"Surface: {cylinder.area():.2f}") # 245.04
cone = Cone(radius=4, geometry=5, unit="ft") # geometry = slant height
print(cone.volume_formatted()) # "83.78ft³"
print(cone.area_formatted()) # "113.10ft²"
# Pyramid with square base
pyramid = Pyramid(
base=6, side=5, sidesnumber=4, apothem=4,
side1=6, side2=6, height=8
)
print(pyramid.volume_formatted()) # "96.0cm³"
Platonic Solids
from marksgeometrys import Tetrahedron, Octohedron, Dodecahedron, Icosahedron
tetra = Tetrahedron(side=6, height=5)
print(f"Volume: {tetra.volume():.2f}") # 25.46
print(f"Area: {tetra.area():.2f}") # 62.35
octo = Octohedron(side=4)
print(f"Volume: {octo.volume():.2f}") # 30.17
print(f"Area: {octo.area():.2f}") # 55.43
dodec = Dodecahedron(side=3, apothem=4.1)
print(dodec.volume_formatted()) # "206.90cm³"
icosa = Icosahedron(side=4)
print(icosa.area_formatted()) # "138.56cm²"
Truncated Figures (Frustums)
from marksgeometrys import PyramidTrunk, ConeTrunk
# Pyramid frustum
trunk = PyramidTrunk(
sbside=5, sidesnumber=6, sbapothem=4,
lbside=10, lbapothem=8,
latlargebase=8, latsmallbase=5, latheight=6,
height=10
)
print(trunk.volume_formatted()) # "500.0cm³"
# Cone frustum
cone_trunk = ConeTrunk(sbradius=3, geometry=5, lbradius=5, height=10)
print(cone_trunk.volume_formatted()) # "192.68cm³"
Project Structure
marksgeometrys/
├── marksgeometrys/
│ ├── __init__.py # Exports all classes
│ └── geometry.py # All 24 geometric classes
├── setup.py # PyPI packaging
├── README.md # This file
└── LICENSE.txt # MIT License
Requirements
- Python 3.8+
- No external dependencies (uses only
mathfrom standard library)
Development
# Clone and install in development mode
git clone https://github.com/marc1fino/marksgeometrys.git
cd marksgeometrys
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\Activate.ps1 on Windows
pip install -e .
# Run tests
python -c "
from marksgeometrys import Square, Cube, Octohedron, Sphere
assert Square(side=5).area() == 25
assert Cube(side=3).volume() == 27
assert Octohedron(side=3).volume() is not None # Bug fixed
assert Sphere(radius=1).area_formatted().endswith('cm²')
print('All tests passed!')
"
Version History
- 0.1.1 — Current release
- Numeric returns for
area()/volume() - Added
unitparameter to all classes - Added
area_formatted()/volume_formatted()methods - Fixed Octohedron returning
Nonefor non-zero sides - Proper squared/cubed unit notation (cm², cm³, mm², m³, etc.)
- Numeric returns for
Roadmap
- Add perimeter/circumference methods for 2D shapes
- Add moment of inertia calculations for 3D solids
- Support for composite figures
- Spherical coordinates and vector operations
- Type hints and full mypy compatibility
- Comprehensive test suite with pytest
License
Distributed under the MIT License. See LICENSE.txt for details.
Author
Educational mathematics library for students, engineers, and developers.
Metadata
Release files for marksgeometrys 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| marksgeometrys-0.2.tar.gz | 11.3 kB | Without provenance | Details for marksgeometrys-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| marksgeometrys-0.2-py3-none-any.whl | Python 3 | none | any | Details for marksgeometrys-0.2-py3-none-any.whl |
Total release size: 18.8 kB
Release files / marksgeometrys-0.2.tar.gz
| Download URL | marksgeometrys-0.2.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b327408bb1042813e94fc40f24ce7cbd6e02c48abc0c758a96b6244a61bd42b9
|
|
BLAKE2b-256 checksum How to use checksums |
fe5c1b0d2bb93f5593ae35cef033d62aa4f3a81991db3ebca1d34c71503b675f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / marksgeometrys-0.2-py3-none-any.whl
| Download URL | marksgeometrys-0.2-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d272e12f4d1928fe2db849014d10f7b2a915a965a2eefda7e147163395becbb7
|
|
BLAKE2b-256 checksum How to use checksums |
223ebaf52922d0b139339b24de4dcd97d8812ec943c803616f6a9cdc84377a99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for marksgeometrys 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.