The following is the altitude of a reentry vehicle, on its decent through the atmosphere.
What makes this interesting is the way of execution: notice the browser window? The entire simulation is running in javascript, using my javascript classes jVector and jMatrix. The plot is done in jPlot2D (pre-release), utilizing RaphaelJS.
The mathematics comes from this source.
Posted in Physics, eScience, programming | Comments Off
I have created a small class for handling 3D vectors. It could come in handy if you ever have to do some physics or graphics on a website.
Example:
// Create two vectors
var vec1 = new Vector(1.0, 1.0, 2.0);
var vec2 = new Vector(4.0, 2.3, 5.0);
// Calculate the dot product of the vectors
var scalar1 = vec1.Dot(vec2);
console.log(scalar1); // -->16.3
// Scale vec1 by scalar1
vec1 = vec1.Scale(scalar1);
console.log(vec1); // --> x: 16.3, y:16.3, z:32.6
// Cross product of vec2 and vec1
vec3 = vec2.Cross(vec1);
console.log(vec3); // --> x: -6.519 y: -48.90 z: 27.71
// Get the L2 norm of vec3:
scalar2 = vec3.Norm();
console.log(scalar2); // --> 56.582
// Return vec3 in Spherical coordinates:
sph3 = vec3.Spherical();
console.log(sph3); // --> phi: -1.70, r: 56.58, theta: 1.059
// Calculate ((vec1 + vec2) * vec3) * scalar1
vec4 = vec1.Add(vec2).Mult(vec3).Scale(scalar1);
console.log(vec4); // --> x: -2157.40, y: -14825.50, z: 16982.90
Download here:
Vector
Please post any comments or suggestions.