Skip to content

Instantly share code, notes, and snippets.

View companje's full-sized avatar

Rick Companje companje

View GitHub Profile
@companje
companje / rotation-lat-lon-sphere-unwarp-to-texture-cubemap-lens-projections.pde
Last active February 19, 2025 17:13
Rotation lat/lon Sphere and unwarp to texture, cubemap, lens, projections etc.
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
PGraphics dome, ortho3D, lens, cubemap[] = new PGraphics[6];
PShape globe;
PShader shader;
PImage tex;
float h=512, d=h, hd2=h/2, r=hd2;
int cubemapSize=512;
Rotation qTo = new Rotation(new Vector3D(0, 0, 1), 0);
@companje
companje / lat,lon to Rotation and back.pde
Created February 19, 2025 14:32
lat/lon to Rotation and back
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
GeoPoint nl = new GeoPoint(52.37, 4.91);
GeoPoint ny = new GeoPoint(40.79, -73.96);
GeoPoint jp = new GeoPoint(36.14, 137.86);
GeoPoint north = new GeoPoint(90, 0);
GeoPoint south = new GeoPoint(-90, 0);
GeoPoint west = new GeoPoint(0,-90);
GeoPoint east = new GeoPoint(0,90);
@companje
companje / 3D Sphere to CubeMap to Equirectangular texture.pde
Created February 12, 2025 20:01
3D Sphere to CubeMap to Equirectangular texture
PImage earth;
PShape globe;
PGraphics fbo[] = new PGraphics[6];
int cubemapSize = 1024;
PImage output_texture;
PImage tex;
PGraphics view3D,ortho3D;
float h, hd2;
PVector center[] = {
@companje
companje / CubeMap camera FOV 90 (stretched).pde
Last active February 12, 2025 12:59
CubeMap camera FOV 90 (stretched)
PImage earth;
PShape globe;
PGraphics fbo[] = new PGraphics[6];
int cubemapSize = 512;
PVector eye = new PVector(0, 0, 0);
PVector up[] = {
new PVector(0, -1, 0), // +X
new PVector(0, -1, 0), // -X
@companje
companje / weather.pde
Created February 10, 2025 21:02
Globe Weather API
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
Vector3D focusPoint = latLonToVector3D(0, 0);
Vector3D nl = latLonToVector3D(52.37, 4.91);
Vector3D ny = latLonToVector3D(40.79, -73.96);
Vector3D jp = latLonToVector3D(36.14, 137.86);
Vector3D north = latLonToVector3D(90, 0);
@companje
companje / Sphere-Lat-Lon.pde
Last active January 29, 2025 08:01
Sphere with mouse and rotate to Lat Lon with Apache Math3 library
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
Vector3D nl = latLonToVector3D(52.37, 4.91);
Vector3D ny = latLonToVector3D(40.79, -73.96);
Vector3D zero = latLonToVector3D(0, 0.0001);
Vector3D north = latLonToVector3D(90, 0);
Vector3D south = latLonToVector3D(-90, 0);
Vector3D india = latLonToVector3D(8.2, 77.45);
Vector3D points[] = {nl, ny, zero, north, south, india};
@companje
companje / perspective.pde
Created January 21, 2025 10:58
perspective
float w=2160, h=2160, wd2=w/2, hd2=h/2, wdh=w/h;
float distToCam=1900;
perspective(atan(hd2/distToCam)*2, wdh, distToCam, 10000);
camera(0, 0, -distToCam, 0, 0, 0, 0, 1, 0);
scale(-1, 1, 1);
@companje
companje / sanyo-mbc-555-draw-bitmap-font.asm
Created December 21, 2024 23:37
Sanyo MBC-550/555 - draw bitmap font 12x12px anywhere on the screen
; see also https://companje.nl/sanyo
draw_char:
jmp .__________
; public
.char db 'A'
.ox dw 0
.oy dw 0
.width dw 16
.height dw 12
@companje
companje / wktLiteral to GeoJSON.py
Last active November 29, 2024 13:36
wktLiteral to GeoJSON met shapely
import json
from shapely import wkt
from shapely.geometry import mapping
with open('OSG.json', 'r') as infile:
data = json.load(infile)
geojson_features = []
for item in data:
@companje
companje / HISGIS-unrotate.py
Created November 26, 2024 10:09
HISGIS Unrotate - Automatische berekenen rotatiematrix via keypoint herkenning en vervolgens converteren van Ground Control Points
import cv2,sys,re,json
import numpy as np
from pathlib import Path
input_folder = "../TAB bestanden met afbeelding Ad"
for tab_filename in Path(input_folder).rglob("*.png"):
print(tab_filename)
sys.exit()