Skip to main content

A 2D coordinate geometry library (points, lines, conics, triangles).

Project description

coordgeo

A Python library for Coordinate Geometry — simple, intuitive, powerful.

This library provides mathematical classes (Point, Line, Circle, Ellipse, etc.) and tools for calculations and visualization in 2D geometry. It is built using OOP principles and designed to be easy to use even for beginners.

Installation your_project/ │ ├── main.py └── coordgeo/ ├── init.py ├── point.py ├── line.py ├── circle.py ├── parabola.py ├── ellipse.py ├── hyperbola.py ├── triangle.py └── plotting.py

Then in your Python file:

from coordgeo import *

or

import coordgeo

Quick Start Examples

  1. Working with Points from coordgeo import Point

p1 = Point(3, 4) p2 = Point(8, 7)

print(p1.distance_to(p2)) print(p1.midpoint(p2)) print(p1.rotate(90))

  1. Working with Lines from coordgeo import Point, Line

L = Line.from_points(Point(0, 0), Point(4, 4)) print(L.slope) print(L.contains(Point(2, 2)))

  1. Circles from coordgeo import Circle, Point

c = Circle(center=Point(0, 0), radius=5) print(c.contains(Point(3, 4))) # True print(c.equation())

Creating a circle from a diameter:

c2 = Circle.from_diameter(Point(-3, 0), Point(3, 0))

  1. Triangle properties from coordgeo import Triangle, Point

T = Triangle(Point(0,0), Point(4,0), Point(0,3)) print("Area:", T.area) print("Centroid:", T.centroid) print("Incenter:", T.incenter) print("Circumcenter:", T.circumcenter) print("Orthocenter:", T.orthocenter)

  1. Conics (Parabola, Ellipse, Hyperbola) Parabola from coordgeo import Parabola

P = Parabola(a=2, orientation="right") print("Focus:", P.focus) print("Directrix:", P.directrix) print(P.equation())

Ellipse from coordgeo import Ellipse

E = Ellipse(a=5, b=3) print("Eccentricity:", E.eccentricity) print("Foci:", E.focus_points)

Hyperbola from coordgeo import Hyperbola

H = Hyperbola(a=5, b=3) print("Eccentricity:", H.eccentricity) print("Foci:", H.focus_points) print("Asymptotes:", H.asymptote_slopes)

Visualization (Plotting)

The library supports matplotlib visualization.

Example:

from coordgeo import Circle, Point from coordgeo.plotting import create_axes, plot_circle, show

fig, ax = create_axes()

C = Circle(center=Point(0,0), radius=4) plot_circle(ax, C)

show()

Plot Triangle from coordgeo import Triangle, Point from coordgeo.plotting import create_axes, plot_triangle, show

fig, ax = create_axes()

T = Triangle(Point(0,0), Point(4,0), Point(0,3)) plot_triangle(ax, T)

show()

Importing Strategy Recommended: from coordgeo import Point, Line, Circle

Avoid:

from coordgeo import *

(because it imports too many names into global scope)

Error Handling & Tips

If circles fail to construct from 3 points: Make sure the points are not collinear.

If plotting shows nothing: Ensure you call show() at the end.

If your line equation results in division error: Your line might be vertical — slope is undefined (None).

If conic is rotated or shifted: Currently only standard conics at origin are supported — rotation/translation support is coming later.

Why use this library?

Simple intuitive API Strong mathematical foundation Clear class structure Easy visualization support Excellent for learning coordinate geometry No unnecessary dependencies

License

MIT License — free to use and modify. Author

Developed by Kareem Khan For education, engineering, mathematics, and fun .

Change Log

1.0.0 (30/11/2025)

Initial Release

Introduced core classes:

Point, Line, Circle

Parabola, Ellipse, Hyperbola

Triangle

Implemented geometric computations:

distances, slopes, intersections

tangents & normals

foci, eccentricities, asymptotes

circle & conic geometry

Added construction helpers:

circle from 3 points

line from slope+point

section formula

foot of perpendicular

Provided plotting support (matplotlib) via plotting.py

Added full README.md, library structure, and package documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coordgeo-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file coordgeo-1.0.0.tar.gz.

File metadata

  • Download URL: coordgeo-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for coordgeo-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9e9917e33289d455b3caf688fde8690c09e2f0c321e1c7de4a9c038c2757e2e2
MD5 47defdb04efb9fc2b7de72a9905f4738
BLAKE2b-256 eead06a58a872661f312224daff672c2d3ae0a6e00ab78d34bb0928b228bf429

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page