subdgtl / Monoceros

Wave Function Collapse plug-in for Grasshopper
MIT License
63 stars 13 forks source link

Rules by example: Part 1/2 #28

Closed janper closed 3 years ago

janper commented 3 years ago

Purpose

The user may want to define Rules for existing Modules by assembling them into an example aggregate (or more of them).

Main architecture

From inputs: well-defined Modules and a bunch of geometry, the detector will identify the Modules distributed in space and generate deterministic Slots. In part 2/2 of this Issue the Envelope of deterministic Slots will be scanned for adjacencies and respective Rules will be created.

Issues

  1. In Grasshopper / Rhino there are no easy-to-use references to geometry, therefore the component will have to detect and identify which geometry represents which Module.
  2. Modules with no geometry (i.e. Empty) will be skipped
  3. Issue with indifference and out-Module (see Part 2/2)

Pseudocode

  1. Skip empty Modules
  2. Modules have a Pivot = a plane in the center of the first Module Part. For conventional Modules this means that the Pivot is close to some Module geometry, but this is not guaranteed, as the geometry can be outside the Module cage. Therefore we need to find the longest of closest distances between the geometry and its Pivot = l_max.
  3. Wrap the example geometry into a bounding box and populate it with Slot centers (grid origin and orientation defined by a Base plane).
  4. Grow the Slot centers by l_max \ slot_diagonal_min_coordinate layers
  5. One-by-one copy each Module geometry (use Pivot) onto each Slot center and check if all Module Geometries overlap (are identical) with some example geometry. Optimize by checking bounding boxes first.
  6. If perfect match (consider what to do if there is more example geometry - probably nothing because Module geometries may legally overlap), then place a deterministic Slot (containing the firs Module Part) onto the Pivot and onto all adjacent Slot centers occupied by other Module Parts
  7. Return a collection of deterministic Slots