Skip to main content

Pure Python library for 3D analytical geometry with vectors, points, lines, planes, faces and geometric transformations.

Project description

Pure Python 3D Geometry Custom Vector Engine Object-Oriented No Dependencies Unit Tests MIT License

geom3py

geom3py is a library developed entirely in Pure Python for analytical geometry calculations in three-dimensional space. It features its own vector and linear algebra engine and provides an object-oriented API for vectors, points, lines, planes and faces including geometric transformations such as scaling, rotation, translation and reflection.

The library has no external dependencies and is suitable for teaching and study as well as a foundation for geometric applications, visualization or CAD-related projects.


Features

Vectors (Vector)

  • Vector addition and subtraction

  • Scalar multiplication

  • Magnitude

  • Dot product

  • Cross product

  • Normalization

  • Angle calculation

  • Transformations

    • Scale
    • Translate
    • Rotate
    • Reflect on point
    • Reflect on line
    • Reflect on plane

Points (Point)

  • Creation of points in ℝ³
  • Distance between points
  • Direction vector between two points
  • All geometric transformations

Lines (Line)

  • Creation from

    • two points
    • support and direction vector
  • Calculation of any point on the line

  • Foot point of a point

  • Intercept points

  • Distances to

    • points
    • lines
  • Intersection with lines

  • Positional relationships

    • identical
    • parallel
    • intersecting
    • skew
  • Angle calculations

  • Geometric transformations


Planes (Plane)

  • Creation from

    • point and normal vector
    • point and two direction vectors
  • Foot point of a point

  • Intersection line of two planes

  • Intersection with lines

  • Intercept points

  • Distances to

    • points
    • lines
    • planes
  • Intersection angles

  • Positional relationships

    • identical
    • parallel
    • intersecting
  • Geometric transformations


Faces (Face)

Representation of bounded planar quadrilaterals.

Supports among others:

  • Center point

  • Perimeter

  • Area

  • Normal vector

  • Point-in-face test

  • Positional relationships between faces

    • identical
    • parallel
    • intersecting
    • outside
    • coplanar intersecting
    • coplanar outside
    • on edge
    • touching
    • edge intersecting
  • Distance between faces

  • Intersection point (if unique)

  • Geometric transformations


Properties

  • ✅ Completely in Pure Python
  • ✅ No external dependencies
  • ✅ Custom vector engine
  • ✅ Custom linear algebra helper functions
  • ✅ Object-oriented API
  • ✅ Numerically robust calculations using custom tolerance functions
  • ✅ Geometric transformations for all objects
  • ✅ Extensive unit tests
  • ✅ Suitable for teaching, study and technical applications

Installation

pip install geom3py

# 📚 Examples

## Basic Geometry

```python
from geom3py import Point, Line

A = Point([0, 0, 0])
B = Point([2, 2, 2])

g = Line.from_points(A, B)

print(A.distance_to_point(B))
print(g.point_at(0.5))
print(g.contains_point(A))

Planes

from geom3py import Point, Plane

E = Plane([1, 2, 3], [1, 1, 1])
P = Point([4, 5, 6])

print(E.distance_point(P))
print(E.contains_point(P))
print(E.intercept_points())

Transformations

from geom3py import Line

g = Line([1, 2, 3], [1, 0, 0])

g2 = g.scale(2)
g3 = g.translate([5, 0, 0])
g4 = g.rotate(90, "z")
g5 = g.reflect_on_point([0, 0, 0])

Face

from geom3py import Point, Face

face = Face(
    [0, 0, 0],
    [10, 0, 0],
    [10, 8, 0],
    [0, 8, 0]
)

print(face.area())
print(face.perimeter())
print(face.center)

P = Point([5, 4, 0])
print(face.contains_point(P))

Intersection Between Line and Plane

from geom3py import Line, Plane

g = Line([0, 0, 0], [1, 1, 1])
E = Plane([1, 0, 0], [0, 1, 0])

print(E.position_line(g))
print(E.intersection_line(g))

Angle Calculations

from geom3py import Line, Plane

g1 = Line([0, 0, 0], [1, 0, 0])
g2 = Line([0, 0, 0], [1, 1, 0])

print(g1.angle_lines(g2, deg=True))

E = Plane([0, 0, 0], [0, 0, 1])
print(E.angle_line(g1, deg=True))

E2 = Plane([0, 0, 0], [1, 1, 0])
print(E.angle_plane(E2, deg=True))

Dependencies

  • Python ≥ 3.10

License

MIT License.

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

geom3py-1.0.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geom3py-1.0.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: geom3py-1.0.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for geom3py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 56ee1e7c9184eeae1f873ed1c556c87942b99a106660ace5e4909ec8cdbf888e
MD5 f57c27bb327514542c0b66d0b68cd5d7
BLAKE2b-256 e829bbdb46007892c236c26d7467a6b1bee837c78cff537d2f54d5fc1bbaffc7

See more details on using hashes here.

File details

Details for the file geom3py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: geom3py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for geom3py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1758c086ee8f678b6ddc82d76892b9885b7401072ab51f712fa6795e702df504
MD5 0131db9dacdd91181b7e4e1253982ac8
BLAKE2b-256 72287bbecd02d4c343ffc203b8094a1ac581d4bb01da467c0f1480398f9a9488

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