Skip to content

Instantly share code, notes, and snippets.

View fogleman's full-sized avatar

Michael Fogleman fogleman

View GitHub Profile
@fogleman
fogleman / README.md
Created March 15, 2024 00:43
ChatGPT-generated README for `hmm` based only on its .cpp files

This C++ application is designed to generate 3D models from heightmap images through triangulation, optionally adding solid bases and applying various modifications to the heightmap before processing. It also supports generating normal and hillshade maps based on the input heightmap. Below is a detailed usage guide, including implementation and algorithm details.

Usage

To use this application, you need to compile the provided source files (base.cpp, blur.cpp, heightmap.cpp, main.cpp, stl.cpp, triangulator.cpp, along with their headers) into an executable. The program requires specifying an input heightmap file and various optional parameters to control the output model's characteristics.

./heightmap_to_stl [options] infile [outfile.stl]
@fogleman
fogleman / rubix.py
Created August 14, 2021 18:57
Simple 2x2x2 Rubik's Cube Solver in Python
import sys
# -------
# | 16 17 |
# | Y |
# | 18 19 |
# ------- ------- ------- -------
# | 12 13 | 00 01 | 04 05 | 08 09 |
# | X | Z | X | Z |
# | 14 15 | 02 03 | 06 07 | 10 11 |
@fogleman
fogleman / snowflake.py
Last active December 28, 2021 00:21
Snowflake Generator
import random
import time
# inspiration: https://mathematica.stackexchange.com/questions/39361/how-to-generate-a-random-snowflake
# see https://www.redblobgames.com/grids/hexagons/ for information
# about hexagon grids and coordinate systems
# neighbors in axial coordinates
DIRS = [(1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1)]
- Install & launch
$ brew install syncthing
$ brew services start syncthing
- Install it on your Linode or whatever too
- https://apt.syncthing.net/
- Visit local dashboard at http://localhost:8384/
- Click `Add Remote Device` to sync with another machine
@fogleman
fogleman / main.cpp
Last active March 8, 2021 22:31
Gray-Scott Reaction-Diffusion with OpenCL
#define CL_SILENCE_DEPRECATION
// #if defined(__APPLE__) || defined(__MACOSX)
// #include <OpenCL/cl.hpp>
// #else
// #include <CL/cl.hpp>
// #endif
#include "cl.hpp"
import cairocffi as cairo
import numpy as np
import random
def random_coefs(order, sigma):
return [random.gauss(0, sigma) for _ in range(order)]
def random_transform():
y_dx = random_coefs(5, 0.3)
y_dy = random_coefs(5, 0.3)
@fogleman
fogleman / heightmap2stl.py
Created August 22, 2018 16:45
Heightmap to 3D Mesh
from PIL import Image
from pyhull.delaunay import DelaunayTri
from shapely import geometry
from skimage import measure
from scipy import interpolate
import math
import numpy as np
import struct
import sys
@fogleman
fogleman / floats.c
Created July 30, 2018 13:07
How many floats between -1 and 1?
#include <stdint.h>
#include <stdio.h>
typedef union {
uint32_t a;
float b;
} float_or_int;
int main() {
float_or_int u;
package main
import (
"image"
"image/color"
"math"
"math/cmplx"
"github.com/fogleman/fauxgl"
"github.com/fogleman/gg"
@fogleman
fogleman / isoline.go
Created February 16, 2018 04:11
Heightmap to Isolines
package main
import (
"fmt"
"image"
"image/draw"
"image/png"
"math"
"os"