• Stars
    star
    953
  • Rank 47,957 (Top 1.0 %)
  • Language
    Clojure
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

2D/3D geometry toolkit for Clojure/Clojurescript

thi.ng/geom

./assets/svo-d7.jpg

Contents

About the project

Status

The project was in active, almost daily development from late 2011 - summer 2016 during its 4th iteration/rewrite cycle. Originally developed in a Literate Programming style using Emacs & Org-mode, in May 2018 it was decided to revert to a traditional Clojure project setup to encourage more contributions from other interested parties. The original .org source files are kept for reference in the ./org/ directory until further notice.

Regardless of version number, the library is mature and has been used successfully in several commercial projects over the past 10 years and can be considered stable for most use cases.

Leiningen coordinates

[thi.ng/geom "1.0.0"]

Additional dependencies for JOGL

If you’re intending to use this library’s OpenGL functionality under Clojure (not ClojureScript), the following additional native dependencies must be added to your project (for each platform you intend to use):

[org.jogamp.gluegen/gluegen-rt "2.3.2" :classifier "natives-macosx-universal"]
[org.jogamp.jogl/jogl-all "2.3.2" :classifier "natives-macosx-universal"]

The full list of supported platform :classifier’s:

natives-android-aarch64.jar
natives-android-armv6.jar
natives-linux-amd64.jar
natives-linux-armv6.jar
natives-linux-armv6hf.jar
natives-linux-i586.jar
natives-macosx-universal.jar
natives-solaris-amd64.jar
natives-solaris-i586.jar
natives-windows-amd64.jar
natives-windows-i586.jar

Overview

thi.ng/geom is a comprehensive and modular geometry & visualization toolkit for Clojure/ClojureScript. It provides a large set of purely math & geometry oriented data types, a polymorphic, largely protocol based API to transform/convert types and various ways to create interactive visualizations in SVG, WebGL, OpenGL, both in the browser and in desktop environments.

Embracing Clojure’s approach of data transformations, the library’s core philosophy is based on a functional approach to generative design tasks with hundreds of hours spent on refining & optimizing the core API for both Clojure & Clojurescript.

Unlike most other open source projects, this project has been developed in a literate programming style and has been in active, regular development since late 2011, currently in its 4th iteration/rewrite cycle.

You’re highly encouraged to consult the source code, which contains documentation, examples, diagrams and general usage pattern hints.

This project is part of the thi.ng collection of Clojure & Clojurescript libraries and makes uses of several other projects in this collection (see dependencies further below).

Example usage

A growing number (currently ~40) of small examples are included in this repo under the /examples directory:

Interactive examples:

Growing list of thi.ng workshop repositories (These workshops were running on a monthly basis & internationally in 2015/2016):

  • WS-LDN-1
  • WS-LDN-2
  • WS-BLN-1
  • WS-LDN-5 (WebGL, source code forthcoming)
  • WS-LDN-6 (Desktop apps, OpenGL/WebGL, source code forthcoming)
  • WS-LDN-8 (WebGL, WebRTC, Web workers, asm.js)

A preliminary list of other projects using this library:

Project structure

Use the diagram below to quickly navigate to any namespace in the project. Nodes in the graph have tooltips with a brief description of each namespace. Note: Due to GH restrictions on SVG files, first click anywhere on the diagram before trying to navigate to a specific namespace.

http://dev.thi.ng/geom/overview2.svg

Main features (non-exhaustive list)

  • Comprehensive & optimized 2D/3D vector & matrix algebra / transformations
  • Custom, optimized vector types w/ GLSL style vector swizzling & full Clojure sequence API support
  • Unified, easy-to-learn & extensible core API defined via ~50 polymorphic protocols
  • Unified OpenGL (v3.3+) & WebGL abstractions of common features, shader, buffer & texture utilities
  • Declarative GLSL shader specs and code generation
  • Optional OpenGL/WebGL shader presets based on thi.ng/shadergraph
  • Declarative OpenGL/WebGL FBO-based multi-pass shader pipeline creation & execution tools
  • OpenGL helpers for desktop apps (wrapping JOGL)
  • React.js component helpers for WebGL
  • 3D SVG mesh renderer with software facet shader support
  • SVG generation API & optional conversion of geom types
  • Declararitve 2D data visualization module with various modes (area, bar, line, scatter, contours, stacks etc., cartesian/polar axes)
  • 35+ custom (mainly immutable) geometry types implementing core protocols
  • Shape analysis (surface area, circumference, distance & volume calculations) for all implemented types
  • 2D/3D intersection & classification checks (vs. point, line, ray, shapes)
  • Access entities as graph-like structures (vertices/edges)
  • 2D/3D platonic entity to 3D polygon mesh conversion (w/ many options)
  • Optimized conversions to OpenGL/WebGL (with attributes, indexed, non-indexed)
  • Flexible & customizable mesh vertex attribute generators
  • Subdivision meshes (Catmull-Clark, Doo-Sabin, Butterfly)
  • Parallel-transport frame sweep mesh generation from point sequences (skinning with arbitrary profiles, incl. profile morphing)
  • 3D Lathe meshes from 2D curves
  • 2D shape extrusions as 3D mesh (solid or walled)
  • Delaunay triangulation of 2D point clouds
  • Tesselation of simple 2D polygons (no holes)
  • Basic SVG <path> parsing with different segment types
  • Basic insetting of simple 2D polygons (no miter support)
  • Shape subdivision (only lines, triangles, rects, quads, tetrahedrons)
  • Shape boundary sampling (at fixed resolution or uniform distance)
  • Sutherland-Hodgeman clipping of 2D polygons
  • 3D Boolean (CSG) operations on meshes (union, difference, intersection)
  • 3D geometry export (PLY, STL, OBJ, OFF formats)
  • 3D mesh repair tools (T-junctions, unify vertices etc.)
  • 2D/3D particle based Verlet Physics with customizable behaviors & constraints
  • 2D convex hull
  • 2D/3D quadtree/octree (mutable) for fast spatial indexing
  • Automatic curve generation from point seqs (cubic, Chaikin etc.)
  • Unfolding of 3D meshes to 2D (WIP) for digital fabrication

API scope

Since the core library does only deal with pure “platonic” geometry types, it doesn’t directly address any display or rendering functionality at all. However a number of support modules are provided, incl. OpenGL 3/4, WebGL & SVG support, to allow visualizing results and/or exporting generated assets. 2D/3D shape/mesh exporters are provided as well and together with sister libraries like thi.ng/luxor, it’s also possible to generate complete 3D scenes for high quality & high resolution non-realtime rendering using Luxrender now LuxCoreRender.

Furthermore, providing all functionality under a common API for both Clojure & Clojurescript, makes it trivial to offload heavy operations (e.g. large mesh processing) to the server side.

Project structure

core

source

These namespaces define the core functionality of this library, including the approx. 50 protocols and implementations of fundamental geometry types/functions like 2d/3d vector algebra, matrices, quaternion (+ related convenience constructors & conversions)

types

source

This directory contains all high-level 2d/3d data types with their implementations of the various core protocols. From a user perspective, these namespaces defined here provide most of this project’s core functionality.

utils

source

A number of often needed utility functions to deal with point collections, normals, path sampling, triangle properties etc. Also included here are shape intersection tests, curve subdivisions and 2D Delaunay triangulation.

mesh

source

Several tools & operations related to working with 3d meshes, incl. I/O, subdivisions, repair / cleaning, CSG / Boolean mesh merge, mesh generators (polyhedra, lathe etc.)

physics

source

This module provides a simple 2d/3d particle-based physics engine with Verlet integration and support for custom behaviors and constaints, both for individual particles and global. Particles can be connected with springs of varying stiffness as well as made interdependent using positive or negative force fields (attractors).

svg

source

A module to help with building SVG based visualizations of geom entities using hiccup compatible syntax. Includes a customizable 3D mesh renderer w/ software shader support.

viz

source

Declarative, highly customizable 2D data visualization module with ~10 different layout methods, 3 axis types, cartesian and polar domain support. Currently SVG only, but planned to be format-independent.

voxel

source

An experimental implementation of a in-memory sparse voxel tree (SVO) and related functionality to extract isosurface polygon meshes from the tree.

OpenGL & WebGL

source

This module provides a unified API to common OpenGL/WebGL functionality (context creation, shader management & presets, buffer management, textures, FBO etc.), as well as a number of optimized mesh types, conversion & rendering functions, cameras etc. to simplify the use of other geometry types defined in this project with OpenGL, both on the desktop and in the browser. The Clojure version wraps JOGL.

Release history & changelog

See CHANGELOG.org for further details.

VersionReleasedLein coordinatesTagged Github URL
1.0.02023-01-22[thi.ng/geom "1.0.0"]1.0.0
1.0.0-RC52022-04-23[thi.ng/geom "1.0.0-RC5"]1.0.0-RC5
1.0.0-RC42019-10-07[thi.ng/geom "1.0.0-RC4"]1.0.0-RC4
1.0.0-RC32018-06-01[thi.ng/geom "1.0.0-RC3"]1.0.0-RC3
1.0.0-RC22018-06-01[thi.ng/geom "1.0.0-RC2"]1.0.0-RC2
1.0.0-RC12018-05-31[thi.ng/geom "1.0.0-RC1"]1.0.0-RC1
0.0.9082015-11-08[thi.ng/geom "0.0.908"]r908
0.0.8812015-06-21[thi.ng/geom "0.0.881"]r881
0.0.8592015-06-15[thi.ng/geom "0.0.859"]r859
0.0.8562015-06-14[thi.ng/geom "0.0.856"]r856
0.0.8152015-06-01[thi.ng/geom "0.0.815"]r815
0.0.8032015-05-26[thi.ng/geom "0.0.803"]r803
0.0.7832015-04-27[thi.ng/geom "0.0.783"]r783
0.0.7702015-03-29[thi.ng/geom "0.0.770"]r770
0.0.7432015-03-23[thi.ng/geom "0.0.743"]r743
0.0.7372015-03-22[thi.ng/geom "0.0.737"]r737
0.0-7252015-03-15[thi.ng/geom "0.0-725"]r725
0.0-7152015-02-25[thi.ng/geom "0.0-715"]r715
0.0-7092015-02-22[thi.ng/geom "0.0-709"]r709
0.2.02014-03-10[thi.ng/geom "0.2.0"]0.2.0

Contributors

License

(c) 2013 - 2023 Karsten Schmidt

This project is open source and licensed under the Apache Software License 2.0.

More Repositories

1

umbrella

⛱ Broadly scoped ecosystem & mono-repository of 198 TypeScript projects (and ~175 examples) for general purpose, functional, data driven development
TypeScript
3,330
star
2

tinyalloc

malloc / free replacement for unmanaged, linear memory situations (e.g. WASM, embedded devices...)
C
768
star
3

org-spec

Org-mode skeleton for technical specifications & HTML theme
CSS
301
star
4

morphogen

3D form evolution through tree based transformations
Shell
165
star
5

fabric

Signal/Collect inspired compute graph infrastructure for Clojure & Clojurescript
Shell
156
star
6

color

CLJ/CLJS library for color conversion & manipulation
Shell
148
star
7

raymarchcl

Experimental OpenCL voxel rendering/raymarching via Clojure REPL (from 2013)
C
135
star
8

synstack

Modular soft synth & Forth based VM for audio DSL experiments aimed at embedded devices
C
115
star
9

houdini

Houdini HDAs & sketches (VEX, OpenCL, Python)
114
star
10

c-thing

Geometry related data structures (C11)
C
107
star
11

trio

Datatype agnostic triple store & query engine API
Shell
79
star
12

babel

A Leiningen project template for literate Clojure projects w/ org-mode
Clojure
75
star
13

luxor

Clojure based LXS scene graph compiler, generator & mesh exporter for Luxrender
Shell
75
star
14

ws-ldn-12

ARM / STM32F7 DIY synth workshop
C
73
star
15

shadergraph

WebGL/GLSL shader library & dependency framework for ClojureScript
Shell
60
star
16

cgg

Online cosine gradient generator for use w/ thi.ng/color
Clojure
59
star
17

tpl-umbrella-fxhash

Project template repo for generative art projects on the fx(hash) platform
TypeScript
52
star
18

charlie

TypeScript based Forth-like VM w/ online REPL and extensive kernel (incl. WebGL/WebAudio support)
TypeScript
46
star
19

ws-ldn-4

Interactive DIY Synth / ARM baremetal workshop (London, 23-24 January 2016)
C
39
star
20

vexed-generation

Polymorphic helper functions & geometry ops for Houdini VEX / OpenCL
C
38
star
21

ct-gui

Small C11 GUI library (currently only for STM32)
C
38
star
22

ws-ldn-8

High Performance ClojureScript - WebGL, GPU computing, asm.js & Web workers
Clojure
33
star
23

math

Common math functions, macros & utilities for Clojure/Clojurescript
Shell
32
star
24

zig-thing

Small collection of data types/structures, utilities & open-learning with Zig
Zig
30
star
25

ws-ldn-10

Generative design workshop (Clojure/ClojureScript)
Clojure
30
star
26

ndarray

Clojure/Clojurescript port of ndarray core JS library w/ extended features
Shell
27
star
27

validate

Spec based validation & correction for nested data structures, wildcard support, no macros
Clojure
27
star
28

ws-ldn-2

Clojure/Clojurescript workshop (11-13 Nov 2015, London)
Clojure
26
star
29

simplecl

Easy to use OpenCL wrapper for Clojure
Clojure
25
star
30

blog

Current blog posts and consolidated historical articles from various other blog platforms used previously
TypeScript
23
star
31

tweeny

Clojure
23
star
32

ws-ldn-1

Clojure/Clojurescript workshop (2-4 Nov 2015, London)
Clojure
23
star
33

ws-ldn-3

DIY Synth / ARM baremetal workshop (London, 5-6 December 2015)
C
22
star
34

monopub

Lightweight & fast monorepo publish/release/changelog manager to automate releases using nothing more than Conventional Commits.
TypeScript
20
star
35

dstruct

Data structures & utilities for CLJ/CLJS
Shell
20
star
36

talks

Slides & source code of various talks given
JavaScript
18
star
37

font

Generated, modular typeface based on thi.ng wordmark
TypeScript
18
star
38

tpl-umbrella-zig

Minimal thi.ng/umbrella browser project template for hybrid TypeScript & Zig apps, using thi.ng/wasm-api for bridging both worlds and Vite as dev tool/server & bundler...
Zig
17
star
39

demos

A collection of small demos using various thi.ng libraries
Clojure
16
star
40

create-hdom-app

New project generator for @thi.ng/hdom TypeScript apps
TypeScript
16
star
41

cljs-log

Logging macros for Clojurescript
Clojure
15
star
42

punchcard

Customizable Git commit punchcard visualizations
Clojure
15
star
43

ws-ldn-7

DIY Synth & GUI workshop with STM32F7
C
13
star
44

crypto

Small Clojure lib to provide basic GPG keypair generation, encryption & decryption facilities
Clojure
13
star
45

structgen

Clojure library for parsing and seamless working with native C structs/structured byte buffers
Clojure
12
star
46

img2array

CLI util to convert images in various formats to C arrays in various bit depths
C
12
star
47

ws-beo-1

ARM/STM32 DIY synth workshop @ Resonate 2016
C
12
star
48

ws-ldn-11

High Performance ClojureScript - WebGL, WebRTC, Web workers & asm.js
Clojure
10
star
49

typedarrays

Clojurescript wrapper & convenience functions for JavaScript typed arrays
Shell
10
star
50

awesome.thi.ng

User showcase of thi.ng projects in the wild
9
star
51

thingybot

Modular, command driven twitter bot
Clojure
9
star
52

asm.thi.ng

Static site generator for http://asm.thi.ng
Clojure
9
star
53

ct-head

Common utility headers & macros for c.thi.ng projects
C
7
star
54

domus

Clojurescript DOM creation & helpers
Shell
7
star
55

macromath

Macro based inline expanded math expressions for Clojure/Clojurescript
Shell
6
star
56

strf

Extensible string formatters & number parsers for Clojure/Clojurescript
Shell
5
star
57

common

Utility belt of datastructures and functions shared by other thi.ng libraries
Shell
5
star
58

ws-bra-1

Digital Fabrication workshop at Sensorium, Bratislava 2016
Clojure
5
star
59

fourier

Audio analysis (FFT etc.), MP3 playback & time/frequency domain visualization for Clojure
Clojure
5
star
60

xerror

CLJ/CLJS error throwing functions
Clojure
5
star
61

perforate-x

Benchmarking helpers for Clojure & Clojurescript
Clojure
4
star
62

ws-ldn-6

Workshop repo: Building Clojure / ClojureScript desktop apps with OpenGL, OpenCL & Electron
Clojure
4
star
63

edit-any

Triplestore based, semantic wiki engine w/ faceted navigation, build with thi.ng/trio
Clojure
4
star
64

ws-ldn-9

Fast Track to Clojure / ClojureScript (Beginner) workshop
Clojure
4
star
65

tpl-umbrella-basic

Bare-bones template repo for thi.ng/umbrella browser-based projects (TypeScript, Vite, Tachyons)
HTML
4
star
66

ws-mz-1

Clojure
3
star
67

indicators

ES6 Iterators of technical indicators for statistical / financial analysis
TypeScript
3
star
68

egf-language-support

VSCode language support for Extensible Graph Format (https://thi.ng/egf)
3
star
69

jogl-foo

Tiny (temporary) test project for using JOGL w/ thi.ng/geom
Clojure
3
star
70

ldk-couchdb

CouchDB storage adapter for thi.ng/trio (formerly LDK, Linked Data Kit)
Clojure
2
star
71

ct-fat

Dynamically typed proglang experiment based on fat pointers
C
2
star
72

ldk-core

Precursor of thi.ng/trio - Lightweight Linked Data tools for Clojure & Clojurescript
Clojure
2
star
73

ldk-redis

Redis storage adapter for thi.ng/trio (formerly LDK, Linked Data Kit)
Clojure
2
star
74

site

Clojure
2
star
75

snippets

yasnippet collection for thi.ng libraries
1
star
76

branding

thi.ng identity assets & generators
1
star
77

imago

media repository server
Clojure
1
star
78

babel-plugin-transform-remove-logger

Babel plugin to remove logging calls for selected log levels
JavaScript
1
star