This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function EarthRadiusInMeters(latitudeRadians) | |
{ | |
// latitudeRadians is geodetic, i.e. that reported by GPS. | |
// http://en.wikipedia.org/wiki/Earth_radius | |
var a = 6378137.0; // equatorial radius in meters | |
var b = 6356752.3; // polar radius in meters | |
var cos = Math.cos(latitudeRadians); | |
var sin = Math.sin(latitudeRadians); | |
var t1 = a * a * cos; | |
var t2 = b * b * sin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LocationToPoint(c) | |
{ | |
// Convert (lat, lon, elv) to (x, y, z). | |
var lat = c.lat * Math.PI / 180.0; | |
var lon = c.lon * Math.PI / 180.0; | |
var radius = EarthRadiusInMeters(lat); | |
var clat = GeocentricLatitude(lat); | |
var cosLon = Math.cos(lon); | |
var sinLon = Math.sin(lon); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RotateGlobe(b, a, bradius, aradius) | |
{ | |
// Get modified coordinates of 'b' by rotating the globe so that 'a' is at lat=0, lon=0. | |
var br = {lat:b.lat, lon:(b.lon - a.lon), elv:b.elv}; | |
var brp = LocationToPoint(br); | |
// Rotate brp cartesian coordinates around the z-axis by a.lon degrees, | |
// then around the y-axis by a.lat degrees. | |
// Though we are decreasing by a.lat degrees, as seen above the y-axis, | |
// this is a positive (counterclockwise) rotation (if B's longitude is east of A's). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# naive.py - by Don Cross | |
# | |
# Illustrates why 4*arctan(1) is not a good way to calculate pi. | |
# Calculates the series 4*(1/1 - 1/3 + 1/5 - 1/7 + ...) | |
import math | |
n = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# better.py - by Don Cross | |
# | |
# Test the formula pi = 4*(arctan(1/2) + arctan(1/3)). | |
# | |
import math | |
def ArctanDenom(d): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# machin.py - by Don Cross | |
# | |
# Test Machin's Formula: pi = 4*(4*arctan(1/5) - arctan(1/239)). | |
# | |
import math | |
def ArctanDenom(d): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# picrunch.py - by Don Cross | |
# | |
# Use Machin's Formula | |
# pi = 4*(4*arctan(1/5) - arctan(1/239)) | |
# to calculate pi to one million places after the decimal. | |
# | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Harmonograph simulation by Don Cross</title> | |
<meta charset="UTF-8" /> | |
<link rel="stylesheet" href="harmonograph.css"> | |
</head> | |
<body> | |
<div><canvas id="GraphCanvas" class="HarmonographCanvas"></canvas></div> | |
<div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
window.onload = function() { | |
function Radians(d) { | |
return d * (Math.PI / 180.0); | |
} | |
class Pendulum { | |
constructor(xamplitude, yamplitude, frequency, phase, halflife) { | |
this.xamplitude = xamplitude; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, body { | |
/* Fit rendered page to screen layout */ | |
top:0; | |
bottom:0; | |
left:0; | |
right:0; | |
position:fixed; | |
} | |
.HarmonographCanvas { |