Git Product home page Git Product logo

deltille's Introduction

Platforms Swift 5.1 License

Deltille

Deltille is a utility framework designed to encapsulate the mathmatical principles and concepts of a coordinate system defined within a regular tiling of a triangular grid.

Installation

To install using Swift Package Manager, add this to the dependencies: section in your Package.swift file:

.package(url: "https://github.com/zilmarinen/Deltille.git", .upToNextMinor(from: "0.1.0")),

Dependencies

Euclid is a Swift library for creating and manipulating 3D geometry and is used extensively within this project for mesh generation and vector operations.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Implementation

Deltille is a lightweight wrapper for the base utility data structures required to get started working with triangular grids. By constraining triangles to a fixed Grid, it is possible to generate triangle vertices for any given Scale by leveraging the natural geometric properties of triangle subdivision.

Triangles

The basic building blocks of Deltille are both the Coordinate and Triangle types which are used together to model equilateral triangle vertex positions along a plane.

//create a triangle at the world origin
let triangle = Grid.Triangle(.zero)
    
//generate triangle vertices for the desired scale
let vertices = triangle.corners(for: .chunk)

Stencils

A Stencil can be used to subdivide a triangle into individual sub-triangles mapped to a specific grid scale.

//subdivide into stencil components
let stencil = triangle.stencil(for: .tile)
    
//grab the stencil center
let vertex = stencil.vertex(for: .center)

Footprints

A Footprint defines a collection of triangles centered around a given origin.

//define a collection of triangle coordinates
let septomino = Grid.Septomino.asterope
    
//create a footprint    
let footprint = Footprint(origin: .zero,
                          coordinates: septomino.coordinates)
    
//rotate footprint around its origin
let rotated = footprint.rotate(rotation: .clockwise)

Examples

Regolith makes usage of the concepts introduced by Deltille to generate meshes for predefined tessellations of a triangle interior using Ortho-Tiling.

Verdure implements additional mesh generation on top of Deltille to create stylised foliage canopies constrained to a triangular grid.

Credits

The Deltille framework is primarily the work of Zack Brown

Special thanks go to;

  • Boris the Brave for his extensive articles on grid systems, dual contouring, marching cubes, ortho-tiling and so much more.
  • Oskar Stalberg for inspiring posts on procedural generation and wave function collapse.
  • Amit Patel for stimulating deep dives into hexagonal grids, coordinate systems and grid edge classifications.

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.