Ladybug geometry is a Python library that houses all of the basic geometry computation needed for Ladybug Tools core libraries.
Project description
ladybug-geometry
Ladybug geometry is a Python library that houses geometry objects used throughout the Ladybug Tools core libraries.
API Documentation
Reasons for this Library
We initially debated whether geometry computation should be placed largely on the CAD plugins or whether it should be inincluded in the core. As we developed the core libraries out, it became clear that there are large advantages to having it in the core (ie. cross compatability between the CAD plugins, ability to process more inputs from command line, and shear speed since the CAD libraries are made to address many more geometric use cases than are typically needed). So we have decided to include geomtery computation as part of the Ladybug Tools core.
We looked into using other geometry computation libraries for the core including:
However, Rhino3dm lacks basic types of computation that is needed in the core (like generating a grid of points from a surface). Furthermore, Blender library only works in Python3 and this would break our workflows for the Grasshopper and Dynamo plugins, where rely on IronPython. Topologic seems to have many things that we need but it appears that it has C dependencies, making it unusable from ironpython. Furthermore, its dual license may create some difficulties for certain use cases of Ladybug Tools.
After considering it further, we realized that many of the calculations that we need can be done fairly easily as long as the geometry is planar. Since all of the geometry going to the engines (Radiance, E+) is eventually converted to a planar format anyway, we made the decision that the core libraries will support certain basic types of geometry computation for planar objects only. We planned to do this by taking the most relevant parts of existing open source geometry libraries, including euclid and OpenStudio. Thus this repository was born!
For this library, we can borrow some of the math from the previous open source libaraies listed above (Rhino3dm and Blender), as well as other projects like this PhD on Grid Generation for Radiance to build tis core library.
Things that Are or Will be a Part of this Library
(We Can do Easily in Pure Python)
- Vectormath (already exists in Ladybug core)
- Calculate Bounding Box (already exists in Butterfly core)
- Compute Triangle + Quad Areas, Center Points + Normals (partly exists in Butterfly core)
- Compute Area + Perimeter of Planar Geometry (should be doable by using this formula)
- Check Concavity of a 2D Geometry (already exists in legacy find non-convex component)
- Convert Concave 2D Geometry to Convex Geometries (should be possible with the ear clipping method)
- Triangulate Planar Geometry (possible by converting convex geometry to concave and using fan triangulation)
- Move Geometry (can be taken from Rhino3dm)
- Rotate Geometry Around a Base Point (can be taken from Rhino3dm)
- Mirror Geometry (can be taken from Rhino3dm)
- Scale Geometry from a Base Point (can be taken from Rhino3dm)
- Is Point Inside 2D Polygon (look pretty straightforward from this example)
- Planar surface grid generation (as done in this thesis, which uses bounding box and is point inside)
- Glazing Based on Ratio (currently implemented in legacy glazing based on ratio component)
- Solve Adjacencies (possible with good geometric equivalency tests)
- Generate louvers, fins and overhangs from a face. Should be easy by extruding intersected line segments generated from the Face3D.intersect_plane method that is already implemented.
- Check if a 3D PolyFace is Closed (should be possible by creating a 3D triangulated mesh)
- Ensure that all faces of a solid PolyFace are facing outward (possible with a 3D version of the current method that checks whether a point is inside a polygon. Essentially, shoot a ray from the center of a face using the face normal and make sure that the ray intersects 0 or an even number of other faces in the polyface)
- Check if a Point is Inside a Closed 3D Geometry (useful for thermal comfort studies where points in a grid must be matched with zone results) (should be possible with a variation of the function that checks if a face is outward-facing except we use the point in question as the origin of the ray we shoot)
- Straight Skeleton Methods (currently implemented in legacy core/perimeter component but should be expanded to accept concave geometry)
- Offset edge curve of a planar surface (can be done by translating vertices along the straight skeleton to make a "wavefront")
Things That Should be a Part of this Library
(We Think We Can Do Them But They Will Require Some Expertise)
- Create Matching Zone Surfaces (intersection of surfaces with one another). OpenStudio has methods for this as @saeranv shows here
- Curve Boolean a set of 2D curves (useful for finding outer boundaries of set of THERM polygons, calculating building footprints from floor curves, and more). Should be possible with this method here
Things that We Will Rely on the CAD Interface For:
- Conversion of Curved Surfaces to Planar Surfaces (ideally with methods for treating single curvature differently than double curvature)
- Solid Boolean Unions (we can probably get away with not needing this for anything in Ladybug Tools)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ladybug_geometry-1.22.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32fb678a48c263a91d8621bbd82d37df9c356c17fa685ffa002a754826ae7fb8 |
|
MD5 | 5875794bc0fdb031c60d25156ed316a2 |
|
BLAKE2b-256 | c8fd9a98f7bded5ccb0b431f439f72cca51bed1fac608e37da65401c80c3eb28 |