Skip to content

Instantly share code, notes, and snippets.

@retroplasma
retroplasma / OBB_RAY_INTERSECT.js
Last active September 8, 2022 13:41
Ray intersection with oriented bounding box (OBB)
const vec_sub = (a, b) => ({ x: a.x - b.x, y: a.y - b.y, z: a.z - b.z });
const vec_dot = (a, b) => a.x * b.x + a.y * b.y + a.z * b.z;
const vec_len = a => Math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
const vec_norm = a => {
const norm = vec_len(a);
return { x: a.x / norm, y: a.y / norm, z: a.z / norm };
}
/*
* JS version of
@retroplasma
retroplasma / BINSYNC.md
Last active February 16, 2024 15:32
Private Incremental File Storage on Usenet

binsync logo

Private Incremental File Storage on Usenet

Disclaimer

This is just a concept. Don't spam the Usenet.

How Usenet works

Usenet is an old replicated network that is basically a giant forum. There are many providers that offer access to it. Clients use NNTP to read and write articles in newsgroups. A newsgroup is like a directory that contains a stream of articles that each have a unique message ID.

"use strict"
/**************************** config ****************************/
const PLANET = 'earth';
const URL_PREFIX = `https://kh.google.com/rt/${PLANET}/`;
/****************************************************************/
const { getPlanetoid, getBulk, traverse } = require('./lib/utils')({
URL_PREFIX, DUMP_JSON_DIR: null, DUMP_RAW_DIR: null, DUMP_JSON: false, DUMP_RAW: false
});
@retroplasma
retroplasma / obb_dump_obj.js
Last active January 19, 2019 08:23
Dumps oriented bounding boxes of first bulk metadata to obj files. Place in repo's main directory before executing.
"use strict"
const fs = require('fs-extra');
const path = require('path');
/**************************** config ****************************/
const PLANET = 'earth';
const URL_PREFIX = `https://kh.google.com/rt/${PLANET}/`;
const DL_DIR = './downloaded_files';
const [RESEARCH_DIR, DUMP_JSON_DIR, DUMP_RAW_DIR] = ['research', 'json', 'raw'].map(x => path.join(DL_DIR, x));