Skip to content

Instantly share code, notes, and snippets.

View dcousens's full-sized avatar
🇺🇦

Daniel Cousens dcousens

🇺🇦
View GitHub Profile
@dcousens
dcousens / ws.js
Created July 26, 2024 04:08
tiny 1-way websocket for prototyping
// MIT License
//
// Copyright (c) 2021 Daniel Cousens
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@dcousens
dcousens / heightmap.py
Last active June 9, 2017 23:53
Prototype of the midpoint displacement algorithm, also known as the diamond square algorithm.heightmap.py creates a triangular mesh represented as a list vertices and indices from a 2d normalized array of values and some parameters. Commonly used as a heightmap.
import itertools
def get_verts_indices_for_heightmap(heightmap, stepx, stepy, minz, maxz):
""" heightmap assumed to be normalized (values between 0 and 1)
"""
height = len(heightmap)
width = len(heightmap[0])
spanz = maxz - minz
# n_heightmap = width * height