Skip to content

Instantly share code, notes, and snippets.

const radians = deg => deg * Math.PI / 180
// @param {Number} z Offset from radius
export default function convertLatLngToSphere (lat, lng, baseRadius, z) {
// radians
const phi = radians(lat)
const theta = radians(lng - 180)
const radius = baseRadius + z
var p1={
x:0,
y:0
};
var p2={
x:0,
y:1
};
@miketahani
miketahani / tree.md
Created April 9, 2020 03:42 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

// for use with pixel buffers, like the one you get from CanvasRenderingContext2D.getImageData(...).data
const getIndexFromCoordinates = (x, y, imageWidth) => y * (imageWidth * 4) + x * 4
const getCoordinatesFromindex = (index, imageWidth) => [
(index / 4) % imageWidth,
Math.floor((index / 4) / imageWidth)
];
// for use with normal arrays where one element represents a cell in a ROWSxCOLS grid
const getIndexFromCoordinates = (x, y, width) => x + y * width;
@miketahani
miketahani / README.md
Created November 10, 2019 19:09 — forked from veltman/README.md
Flocking boids
@miketahani
miketahani / FullExtStats-Table-1.csv
Last active April 11, 2018 01:07
data for use in Observable
We can't make this file beautiful and searchable because it's too large.
year,state,County,fips,State_Reported_Cases
2008,Alaska,"Juneau City and Borough, Alaska",2110,80
2008,Alaska,"Matanuska-Susitna Borough, Alaska",2170,253
2008,Alaska,"Kenai Peninsula Borough, Alaska",2122,115
2008,Alaska,"Bethel Census Area, Alaska",2050,19
2008,Alaska,"Kodiak Island Borough, Alaska",2150,16
2008,Alaska,"Sitka City and Borough, Alaska",2220,14
2008,Alaska,"Ketchikan Gateway Borough, Alaska",2130,41
2008,Alaska,"Anchorage Municipality, Alaska",2020,2271
2008,Alaska,"Fairbanks North Star Borough, Alaska",2090,277
committee_id committee_name report_year report_type image_number line_number transaction_id file_number committee_name entity_type entity_type_desc unused_contbr_id contributor_prefix contributor_name contributor_first_name contributor_middle_name contributor_last_name contributor_suffix contributor_street_1 contributor_street_2 contributor_city contributor_state contributor_zip contributor_employer contributor_occupation contributor_id receipt_type receipt_type_desc receipt_type_full memo_code memo_code_full contribution_receipt_date contribution_receipt_amount contributor_aggregate_ytd candidate_id candidate_name candidate_first_name candidate_last_name candidate_middle_name candidate_prefix candidate_suffix candidate_office candidate_office_full candidate_office_state candidate_office_state_full candidate_office_district conduit_committee_id conduit_committee_name conduit_committee_street1 conduit_committee_street2 conduit_committee_city conduit_committee_state conduit_committee_zip donor_committee_name na
@miketahani
miketahani / instructions.md
Last active April 6, 2018 00:25
images for use in Observable
We can't make this file beautiful and searchable because it's too large.
pgc,absB,Diam,Dist,sgX,sgY,sgZ,objname,GrpID,Filament
2,-20.15,32.57,5217,4631,-1537,1847,UGC 12889,,860.0
12,-19.5,28.0,6635,1839,-6240,1306,MCG -1- 1- 16,,711.0
13,-18.64,14.27,5236,4112,-2712,1775,CGCG 499- 29,,825.0
16,-18.28,14.52,5708,1693,-5327,1158,MCG -1- 1- 17,,711.0
17,-19.3,19.68,9116,4085,-7823,2286,UM 15,,711.5
18,-18.93,19.54,5566,4932,-1669,1968,MCG 8- 1- 19,,860.0
20,-19.43,18.22,7501,2940,-6675,1750,MCG 0- 1- 16,,711.5
30,-20.67,35.04,7747,-6126,-4392,-1789,ESO 12- 12,,768.0
31,-19.06,18.37,6148,-2303,-5694,-265,FAIR 1061,,713.0
@miketahani
miketahani / globalmaptiles.py
Created January 31, 2018 20:40 — forked from tucotuco/globalmaptiles.py
Classes to calculate Tile coordinates
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/