Public
Edited
Nov 17, 2023
Insert cell
Insert cell
Insert cell
function taylor(radians) {
const t3 = Math.pow(radians, 3);
const t5 = Math.pow(radians, 5);
const t7 = Math.pow(radians, 7);

const fact7 = 7*6*5*4*3*2;

return radians - t3/6 + t5/120 - t7/fact7;
}
Insert cell
test = 90
Insert cell
Math.sin(test * Math.PI/180)
Insert cell
taylor((test * Math.PI/180))
Insert cell
test * Math.PI/180
Insert cell
Math.fround(Math.sin(0.005))/6378
Insert cell
central=.0002
Insert cell
beta = 180 - 90 - central;
Insert cell
one=Math.sin(Math.fround(beta*Math.PI/180))/6378.1
Insert cell
Math.sin(central*Math.PI/180)/one
Insert cell
Math.sin(beta*Math.PI/180)
Insert cell
function encode(val) {
//val is 0 to 1
const r = val * 255;
const g = Math.floor(val * 255) / 255;
let fracr = r % 1;

return [fracr, g]
}
Insert cell
function decode(val) {
return val[0]/255.0 + val[1];
}
Insert cell
testE = encode(6553/65535)
Insert cell
decE = decode(testE) * 65535
Insert cell
10/65535
Insert cell
{
const lambda0 = -78.73677825927734;
const phi0 = 42.948787689208984;
const lon = -78.74;
const lat = 42.95;
let phi = lat*(Math.PI/180);
let lambda = lon*(Math.PI/180);
let centerLat = phi0 * (Math.PI/180);
let centerLon = lambda0 * (Math.PI/180);

let rhsf = Math.fround(Math.sin(Math.fround(centerLat))*Math.sin(Math.fround(phi))) + Math.fround(Math.cos(Math.fround(centerLat))*Math.cos(Math.fround(phi))*Math.cos(Math.fround(lambda-centerLon)));

console.log(rhsf);
//let rhs = Math.sin(centerLat)*Math.sin(phi) + Math.cos(centerLat)*Math.cos(phi)*Math.cos(lambda-centerLon);
let c = Math.acos(rhsf);
console.log("c",c)
//let cf = Math.fround(Math.acos(rhsf))
let kprime = c///Math.sin(c);
console.log("kprim",kprime);

let xout = kprime*Math.cos(phi)*Math.sin(lambda-centerLon);
let yout = kprime*(Math.cos(centerLat)*Math.sin(phi)-Math.sin(centerLat)*Math.cos(phi)*Math.cos(lambda-centerLon));

console.log(xout, yout);
console.log(Math.atan2(yout, xout))
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more