Giter Site home page Giter Site logo

killeengeo's Introduction

KilleenGeo

Downloads GitHub release PyPI Documentation Status Code style: black

2D and 3D geometry in Python. This library was originally a part of the DeepDRR package, but has been split out into its own package for easier use in other projects. It contains a lot of custom implementations with no overarching design philosophy, other than getting me through my PhD.

The naming conventions and general approach to coordinate transforms adheres to this tutorial.

It is written solely in Python, and so is not particularly fast. It is also not particularly well-tested, so use at your own risk.

Installation

pip install killeengeo

Usage

import killeengeo as kg

# Define some points in a world coordinate frame
a = kg.point(1, 2, 3) # a point in 3D
b = kg.point(4, 5, 6) # another point in 3D
v = kg.vector(7, 8, 9) # vector
l = kg.line(a, b) # line connecting a and b
pl = kg.plane(a, v) # plane containing a, b, and normal v
# Also supported: line segments, rays

# Define some coordinate frames
world_from_A = kg.FrameTransform.from_translation(a) # coordinate frame with origin at a 
world_from_B = kg.FrameTransform.from_translation(b) # coordinate frame with origin at b

# Transforms to obtain points in those frames
B_from_world = world_from_B.inverse() # transform from B to world
A_from_world = world_from_A.inverse() # transform to A from world

# Transform between the new frames
A_from_B = A_from_world @ world_from_B # transform to B from A

# Objects in the new frame
a_in_A = A_from_world @ a
v_in_A = A_from_world @ v
l_in_A = A_from_world @ l
pl_in_A = A_from_world @ pl

Most of the time kg objects can be treated like numpy arrays, and they are converted to the expected form.

import numpy as np

points = np.array([a, b]) # [2, 3] array where each row is a point
B2A = np.array(A_from_B) # [4, 4] array representing the transform from B to A

Above is the only use of the X2Y naming convention for frame transformations present here. For more information on why this variable naming convention is awful, see this tutorial.

Documentation

Documentation is (maybe) available at killeengeo.readthedocs.io.

killeengeo's People

Contributors

benjamindkilleen avatar liamjwang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.