Skip to content

Instantly share code, notes, and snippets.

@RangerMauve
Last active December 22, 2015 15:39
Show Gist options
  • Save RangerMauve/6493945 to your computer and use it in GitHub Desktop.
Save RangerMauve/6493945 to your computer and use it in GitHub Desktop.
Create a sphere of radius 1 from altitude and azimuth.
function makeVec(altitude,azimuth){
var x, y, z, hyp, vector;
z = Math.sin(altitude);
hyp = Math.cos(altitude);
y = hyp*Math.cos(azimuth);
x = hyp*Math.sin(azimuth);
vector = new Vector(x,y,z);
return vector;
}
//Altitude: vertical(up down)
//Azimuth: horizontal(left right)
//Iterate like this
var grain = 0.01, vectors = [];
for(var az=0; az<Math.TWO_PI; az+=grain)
for(var al=0; al<Math.TWO_PI;az+=grain)
vectors.push(makeVec(al,az));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment