Skip to content

Commit

Permalink
feat(geometry): Adding Geometry Objects (#3)
Browse files Browse the repository at this point in the history
* feat(2d): More 2D Geometries

* Almost Done With All 2D Geometry

... there are just a couple of last things that I need to impelment on Mesh2D.

* Finished All 2D Objects

I still need to write some tests for them but all fundamental 2D objects are now complete.

* Added 1D Objects in 3D Space

* Finished 3D Geometries

I have been doing tests in Rhino just because it is quicker so I am fairly certain that 80% of the code is working.  I will begin writing pure Python tests and (likely) fixing bugs soon.

* Bug Fix to Surface Class

* Update README.md

* More Reliable is_point_inside method

* Documenting Fringe Cases

* Responding to comments by @mostaphaRoudsari

* Found a Better Way to Avoid Mesh Grid Fringe Cases

* Cleaning Up Code

I realized that one of the methods that I added previously did not do what I thought it did so I have removed it.  I also added a method to automatically create a single closed polygon from a shape with a hole.  I ran it through several tests in Rhino and it seems to be working well.  There aren't any cases I can think of that will not work with the general calculation method and I think I can get it to work for shapes with multiple hole just by having it recurse.

* Added the Capability to Have Faces with Holes

... and everything seems to be working well!

* Update dev-requirements.txt

* Finished Tests for Points

* Finished Tests for LineSegment

* Added Test for Ray2D

* Finished Tests for Rays

* More Polygon2D Tests

* More Tests for Mesh2D

* Decided to Remove the Ability to Override Checks

I realized that the overhad for the checks is not that bad and things really get wonky when they can be overridden on the class.

* Finished Tests for Polygon2D

* Finished All 2D Tests

... and fixed a lot of bugs / poor design decisions that were discovered in the process.

* Added Mesh3D Test

* Finished Mesh3D Tests

* Finished Tests for Plane

... and fixed a few bugs found along the way.

* Started Tests for Face3D

* More Face3D Tests

... and I added a method to Plane to test for co-planarity within a certain tolerance.

* Finished Tests

* Added Methods to Test Equivalency of Geometry

This is what I think should be used for solving adjacency and it has been optimized for this purpose.

* Added method to get sub faces by ratio

* Added Methods to Extract Rectangles from Faces

* Updated documentation

* Small Bug Fix in Plane

* Small Bug Fix in Face3D Sub Face Generation

* Finished All Methods for Glazing by Ratio

* Responded to Comments by @mostaphaRoudsari

... and I  realized that I forgot to add in methods last time to split rectangular glazing vertically, which is now added.

* All Geometry Objects are Now Immutable

This has simplified the code a lot and makes it much easier to communicate how to interact with the ladybug_geomtry API.  The only exception to the universal immutability rule is that the colors of mesh objects are set-able.

* Added Methods to Tell if a Face is Inside Another

* Added methods to generate contoured fins (aka. louvers)

* Added Object for Polyface

This should give us everything that we need to build energy model geometry in the way that we do now with honeybee legacy.  There are just a few small methods left that I want to implement on the Polyface3D object to make it consistent with the other objects.

* Added Transform Methods to Polyface

* Added Volume Property to Polyface

* Adding More Polyface tests

* Realized an Important Case that Needs Solving

* Polyface now has good checks for solidity

* Finished Polyface3D

* Fixed a Bug and Added Tests for it

* Responding to @mostaphaRoudsari 's comments on _mesh.py

* Changed Mesh Grid to Use a Scaled Polygon

* Added a Property to Get Upper Left Counter Clockwise Vertices

.. needed for export to EnergyPlus / OpenStudio

* Using try/except instead of if

* Update ladybug_geometry/_mesh.py

Co-Authored-By: Mostapha Sadeghipour Roudsari <sadeghipour@gmail.com>

* Bug Fix for Python Float Tolerance Cases

* Took Out scale_world_origin method

... and I just extended the scale() method.

* Adding __init__ and __repr__ to Base Classes

* Removing __slots__ from Base Classes

I relaized this creates issues

* Typo Fix

* Update README.md
  • Loading branch information
chriswmackey committed May 28, 2019
1 parent 1d08561 commit 4f85aa7
Show file tree
Hide file tree
Showing 40 changed files with 11,143 additions and 1,033 deletions.
54 changes: 28 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,44 @@ 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
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](https://pypi.org/project/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
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](https://www.radiance-online.org/community/workshops/2015-philadelphia/presentations/day1/STADICUtilities-Radiance%20Workshop2015.pdf)
to build tis core library.

# Things that Will be a Part of this Library
### (We Can do Easily in Pure Python)
- [ ] Vectormath ([already exists in Ladybug core](https://github.com/ladybug-tools/ladybug/blob/master/ladybug/euclid.py))
- [ ] Calculate Bounding Box ([already exists in Butterfly core](https://github.com/ladybug-tools/butterfly/blob/master/butterfly/geometry.py))
- [ ] Compute Triangle + Quad Areas, Center Points + Normals ([partly exists in Butterfly core](https://github.com/ladybug-tools/butterfly/blob/master/butterfly/geometry.py))
- [ ] Compute Area + Perimeter of Planar Geometry (should be doable [by using this formula](https://www.mathopenref.com/coordpolygonarea.html))
- [ ] Check Concavity of a 2D Geometry (already exists in legacy [find non-convex component](https://github.com/mostaphaRoudsari/honeybee/blob/master/src/Honeybee_Honeybee.py#L9340-L9410))
- [ ] Convert Concave 2D Geometry to Convex Geometries (should be possible with the [ear clipping method](https://en.wikipedia.org/wiki/Polygon_triangulation))
- [ ] Triangulate Planar Geometry ([possible by converting convex geometry to concave and using fan triangulation](https://en.wikipedia.org/wiki/Polygon_triangulation))
- [ ] Check if a 3D Geometry is Closed ([should be possible by creating a 3D triangulated mesh](https://gamedev.stackexchange.com/questions/61878/how-check-if-an-arbitrary-given-mesh-is-a-single-closed-mesh/61886))
- [ ] 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](https://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/))
- [ ] Planar surface grid generation ([as done in this thesis](https://www.radiance-online.org/community/workshops/2015-philadelphia/presentations/day1/STADICUtilities-Radiance%20Workshop2015.pdf), which uses bounding box and is point inside)
- [ ] Offset edge curve of a planar surface (can be done by translating vertices along the vector in the middle of the vectors to adjacent vertices)
- [ ] Glazing Based on Ratio (currently implemented in legacy [glazing based on ratio component](https://github.com/mostaphaRoudsari/honeybee/blob/master/src/Honeybee_Glazing%20based%20on%20ratio.py))
- [x] Vectormath ([already exists in Ladybug core](https://github.com/ladybug-tools/ladybug/blob/master/ladybug/euclid.py))
- [x] Calculate Bounding Box ([already exists in Butterfly core](https://github.com/ladybug-tools/butterfly/blob/master/butterfly/geometry.py))
- [x] Compute Triangle + Quad Areas, Center Points + Normals ([partly exists in Butterfly core](https://github.com/ladybug-tools/butterfly/blob/master/butterfly/geometry.py))
- [x] Compute Area + Perimeter of Planar Geometry (should be doable [by using this formula](https://www.mathopenref.com/coordpolygonarea.html))
- [x] Check Concavity of a 2D Geometry (already exists in legacy [find non-convex component](https://github.com/mostaphaRoudsari/honeybee/blob/master/src/Honeybee_Honeybee.py#L9340-L9410))
- [x] Convert Concave 2D Geometry to Convex Geometries (should be possible with the [ear clipping method](https://en.wikipedia.org/wiki/Polygon_triangulation))
- [x] Triangulate Planar Geometry ([possible by converting convex geometry to concave and using fan triangulation](https://en.wikipedia.org/wiki/Polygon_triangulation))
- [x] Move Geometry (can be taken from Rhino3dm)
- [x] Rotate Geometry Around a Base Point (can be taken from Rhino3dm)
- [x] Mirror Geometry (can be taken from Rhino3dm)
- [x] Scale Geometry from a Base Point (can be taken from Rhino3dm)
- [x] Is Point Inside 2D Polygon (look pretty straightforward from [this example](https://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/))
- [x] Planar surface grid generation ([as done in this thesis](https://www.radiance-online.org/community/workshops/2015-philadelphia/presentations/day1/STADICUtilities-Radiance%20Workshop2015.pdf), which uses bounding box and is point inside)
- [x] Glazing Based on Ratio (currently implemented in legacy [glazing based on ratio component](https://github.com/mostaphaRoudsari/honeybee/blob/master/src/Honeybee_Glazing%20based%20on%20ratio.py))
- [x] Solve Adjacencies (possible with good geometric equivalency tests)
- [x] 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.
- [x] Check if a 3D PolyFace is Closed ([should be possible by creating a 3D triangulated mesh](https://gamedev.stackexchange.com/questions/61878/how-check-if-an-arbitrary-given-mesh-is-a-single-closed-mesh/61886))
- [x] 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)
- [x] 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](https://github.com/mostaphaRoudsari/honeybee/blob/master/src/Honeybee_SplitFloor2ThermalZones.py) 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 Require Expertise)
- [ ] Solve Adjacencies (I think the OpenStudio code can also address this)
- [ ] Check if a Point is Inside a Closed 3D Geometry (helpful for thermal comfort when one needs to know if a point is in a zone)
### (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](https://github.com/mostaphaRoudsari/honeybee/issues/700)
- [ ] 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](https://stackoverflow.com/questions/2667748/how-do-i-combine-complex-polygons)

# Things that We Will Rely on the Plugins For:
- Conversion of Curved Surfaces to Planar Surfaces (curved geometry meshing)
- Split Closed 3D Volume to Floors (intersection of a volume and a plane)
- Calculate Building Footprints (boolean union floors)
# 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)
18 changes: 3 additions & 15 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
atomicwrites==1.2.1
attrs==18.2.0
certifi==2018.11.29
chardet==3.0.4
coverage==4.5.2
coveralls==1.5.1
docopt==0.6.2
idna==2.8
more-itertools==5.0.0
pluggy==0.8.0
py==1.7.0
pytest==4.1.0
coverage==4.5.3
coveralls==1.7.0
pytest==4.3.1
pytest-cov==2.6.1
requests==2.21.0
six==1.12.0
urllib3==1.24.1
45 changes: 0 additions & 45 deletions ladybug_geometry/_immutable.py

This file was deleted.

Loading

0 comments on commit 4f85aa7

Please sign in to comment.