Skip to main content

codecov Documentation Status Build Status

A simple Python package for working with geometry related operations. See documentation at gbox.readthedocs.io

Installation

pip install --upgrade gbox

Usage

# create 2D points
from gbox import Point2D
>>> p1 = Point2D(0.0, 0.0)
>>> p2 = Point2D(3.0, 4.0)
>>> p1.distance_to(p2)
5.0

# Create a Cirle with center at point and radius 5.0
>>> from gbox import Circle
>>> c1 = Circle(5.0, p1)
>>> c1.area
78.53981633974483
>>> c1.radius
5.0
>>> c1.position
Shape2DPose(x=0.0, y=0.0, orientation=0.0 rad)
>>> c1.bounding_box
[-5.0, -5.0, 5.0, 5.0]

# Working with Angles
>>> from gbox import Angle
>>> import math
>>> g = Angle(math.pi / 4, "rad")
>>> g
Angle(0.7853981633974483, 'rad')
>>> g.degrees
45.0
>>> g == Angle.deg(45)
True
>>> g.cos
0.7071067811865476

# create a ellipse with cetnere at origin, aspect ratio 2 and orientation 45 degrees
>>> import gbox as gb
>>> e = gb.Ellipse(2, 1, major_axis_angle=gb.Angle.deg(45))
>>> e.area
6.283185307179586
>>> e.perimeter
9.688448220547677
>>> e.position
Shape2DPose(x=0.0, y=0.0, orientation=45 deg)
# check point outside the ellipse
>>> e.contains_point((10, 10))
-1
# check point inside the ellipse
>>> e.contains_point((1, 1))
1
# check point on the ellipse
>>> e.contains_point(gb.transform_point_2d(2, 0, angle=gb.Angle.deg(45)))
0  

For Developers

Install dependencies

Setup environment using uv

# clone the repo, if not done yet
git clone https://github.com/gbox/gbox.git  

# install the uv, if not available, from [uv](https://docs.astral.sh/uv/)

# From the repo root do the following to install the venv
uv sync

Release files for gbox 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gbox 1.1.0
File Size Uploaded
gbox-1.1.0.tar.gz 34.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gbox 1.1.0
File Interpreter ABI Platform
gbox-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 71.8 kB

Release files / gbox-1.1.0.tar.gz

Download URL gbox-1.1.0.tar.gz
Size 34.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f609432d980343dd79857a77a3075e89b573319afe768143288491630c573af0
BLAKE2b-256 checksum
How to use checksums
6dfc4249fc73be4bf55e560e858232505765f8b118f97b6ab50c1f24706d8516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gbox-1.1.0-py3-none-any.whl

Download URL gbox-1.1.0-py3-none-any.whl
Size 37.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
563cf8a5e3b612505b274bb93a3d3319389d2bffe0c319c2ff2936769febbc57
BLAKE2b-256 checksum
How to use checksums
7d62b2374f431f868faeb4849c98a477f5469dd8beca7770a90b58eb646770ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page