Skip to content

Instantly share code, notes, and snippets.

@Birdasaur
Birdasaur / gist:a14c498a4f791e0053610e58aa1564b7
Last active February 10, 2024 16:33
JavaFX 3D example on how to arbitrarily rotate one 3D Node to "look at" another.
public static Affine lookAt(Node node, Point3D from, Point3D to, boolean applyTranslate) {
//zVec is "forward"
Point3D zVec = to.subtract(from).normalize();
//ydir is "up"
Point3D ydir = Rotate.Y_AXIS;
Point3D tangent0 = zVec.crossProduct(ydir);
//handle edge case where to location is precisely the "up" direction
if(tangent0.magnitude() < 0.001){
//pick a different axis to use
ydir = Rotate.X_AXIS;
@Birdasaur
Birdasaur / countries-110m.json
Created April 24, 2023 11:40
countries-110m.json
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Birdasaur
Birdasaur / geoBoundaries-MEX-ADM1.topojson
Created April 24, 2023 11:30
geoBoundaries-MEX-ADM1.topojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Birdasaur
Birdasaur / world-110m.json
Created April 21, 2023 12:32
world-110m.json
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Birdasaur
Birdasaur / mexico-capitols.csv
Created April 17, 2023 21:53
mexico-capitols.csv
city lat lng population
Mexico City 19.4333 -99.1333 21505000
Guadalajara 20.6767 -103.3475 5437000
Puebla 19.0333 -98.1833 1576259
Monterrey 25.6667 -100.3 1135512
Mexicali 32.6633 -115.4678 1049792
Villahermosa 17.9892 -92.9281 1013484
Aguascalientes 21.876 -102.296 934424
Mérida 20.97 -89.62 892363
Chihuahua 28.6353 -106.0889 878062
@Birdasaur
Birdasaur / mexico-airports.csv
Created April 17, 2023 21:44
mexico-airports.csv
id ident name latitude_deg longitude_deg elevation_ft
4688 MMAA Aeropuerto Internacional Juan N. Álvarez 16.762118 -99.755473 16
4706 MMCZ Aeropuerto Internacional de Cozumel 20.511425 -86.930287 15
4707 MMDO Aeropuerto Internacional Gral, Guadalupe Victoria 24.125908 -104.533904 6104
4710 MMGL Aeropuerto Internacional Miguel Hidalgo 20.52504 -103.301557 5016
4713 MMHO General Ignacio P. Garcia International Airport 29.09589958 -111.0479965 627
4722 MMLO Aeropuerto Internacional Del Bajío 20.985813 -101.478825 5956
4726 MMMD Aeropuerto Internacional Manuel Crescencio Rejón 20.933384 -89.662621 38
4731 MMMX Aeropuerto Internacional Lic. Benito Juárez 19.435433 -99.082432 7316
4732 MMMY Aeropuerto Internacional Gral. Mariano Escobedo 25.778561 -100.113602 1278
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"title": {"text": {"signal":"'Perception of ' + Color_Variable + ' by Region'" }},
"width": 675,
"height": 500,
"config": {"style": {"cell": {"stroke": "transparent"}}},
"data": [
{
"name": "symbols",
@Birdasaur
Birdasaur / MexicoRegionsISOCodes.csv
Last active April 24, 2023 20:28
MexicoRegionsISOCodes.csv
n_region_wvs_region_country_specific n_region_iso_region_iso_3166_2 Abundant_Corruption_Percent Work_Is_Important_Percent Religion_Very_Important_Percent per_capita_economic_impact_of_violence_in1kPesos Foreign_workers_as_neighbors Neighbors_Of_A_Different_Race Do_not_trust_Foreigners_at_all Neighbors_Homosexuals Prefer_Male_Political_Leaders
MX: Aguascalientes MX-AGU 61.9 90.48 71.43 41.93 14.29 19.05 28.57 23.81 38.09
MX: Baja California de Norte MX-BCN 72 68 40 70.73 8 6 44 38.00 18
MX: Baja California de Sur MX-BCS 72 68 40 70.73 8 6 44 38.00 18
MX: Campeche MX-CAM 62.5 100 75 25.8 0 0 87.5 25.00 25
MX: Chiapas MX-CHP 71.43 84.42 67.53 20.56 9.09 5.19 62.34 12.99 27.27
MX: Chihuahua MX-CHH 64.81 94.44 59.26 57.57 18.52 7.41 46.3 25.93 16.67
MX: Coahuila MX-COA 71.43 80.95 47.62 17.82 19.05 14.29 45.24 35.71 19.05
MX: Colima MX-COL 58.82 94.12 70.59 72.85 5.88 11.76 52.94 17.65 23.52
MX: Distrito Federal MX-CMX 58.94 64.24 26.49 45.58 19.87 23.84 46.36 24.50 31.12
@Birdasaur
Birdasaur / geoBoundaries-ETH-ADM1.topojson
Created March 29, 2023 14:54
Topojson for Ethiopia
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Birdasaur
Birdasaur / Hypersurface3D.java
Created March 28, 2023 19:29
Painting JavaFX 3D surface with crosshair
public void updatePaintMesh() {
//in case the data grid dimensions have changed
//make the painting image the same dimension as the data grid for easy math
diffusePaintImage = new WritableImage(
Double.valueOf(xWidth*surfScale).intValue(),
Double.valueOf(zWidth*surfScale).intValue()
);
//if this is the first time ....
if(null == paintTriangleMesh) {
paintTriangleMesh = new TriangleMesh();