/* * Generated by www.nevyns-lab.com on 2019-08-23T08:20:12+10:00. * * MIT License * * Copyright (c) 2017 Nevyn's Lab * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ var Equations = (function() { /** * The module object is what you will use in your application, but not by that name. * You will reference it in your code as "Equations". */ var module = {}; /** * Momentum */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates momentum. */ var calcMomentumImpl = function( mass, velocity ) { // M = mv mass = 1.0 * mass; velocity = 1.0 * velocity; return mass*velocity; }; /** * Private function that calculates mass. */ var calcMassImpl = function( velocity, momentum ) { // m = M/v momentum = 1.0 * momentum; velocity = 1.0 * velocity; return momentum / velocity; }; /** * Private function that calculates velocity. */ var calcVelocityImpl = function( momentum, mass ) { // v = M/m momentum = 1.0 * momentum; mass = 1.0 * mass; return momentum/mass; }; /** * This public object contains functions for Momentum. * You can reference it in your code as "Equations.Momentum". */ module.Momentum = { type: "momentum", version: "1.0", title: "Momentum", desc: "These calculators can be used to generate data using mass, velocity and momentum.", /** * The public function to calculate momentum. * You can reference it in your code as "Equations.Momentum.calcMomentum( ... )". */ calcMomentum: calcMomentumImpl, /** * The public function to calculate an array of momentum values by varying the mass. * You can reference it in your code as "Equations.Momentum.calcMomentumVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each momentum value. */ calcMomentumVsMass: function( massMin, massMax, massStep, velocity, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcMomentumImpl( value, velocity ) ); value += massStep; } return data; }, /** * The public function to calculate an array of momentum values by varying the velocity. * You can reference it in your code as "Equations.Momentum.calcMomentumVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each momentum value. */ calcMomentumVsVelocity: function( velocityMin, velocityMax, velocityStep, mass, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcMomentumImpl( mass, value ) ); value += velocityStep; } return data; }, /** * The public function to calculate mass. * You can reference it in your code as "Equations.Momentum.calcMass( ... )". */ calcMass: calcMassImpl, /** * The public function to calculate an array of mass values by varying the velocity. * You can reference it in your code as "Equations.Momentum.calcMassVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each mass value. */ calcMassVsVelocity: function( velocityMin, velocityMax, velocityStep, momentum, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( value, momentum ) ); value += velocityStep; } return data; }, /** * The public function to calculate an array of mass values by varying the momentum. * You can reference it in your code as "Equations.Momentum.calcMassVsMomentum( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the momentum value for each mass value. */ calcMassVsMomentum: function( momentumMin, momentumMax, momentumStep, velocity, labels ) { var value = momentumMin; var data = []; while( value <= momentumMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( velocity, value ) ); value += momentumStep; } return data; }, /** * The public function to calculate velocity. * You can reference it in your code as "Equations.Momentum.calcVelocity( ... )". */ calcVelocity: calcVelocityImpl, /** * The public function to calculate an array of velocity values by varying the momentum. * You can reference it in your code as "Equations.Momentum.calcVelocityVsMomentum( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the momentum value for each velocity value. */ calcVelocityVsMomentum: function( momentumMin, momentumMax, momentumStep, mass, labels ) { var value = momentumMin; var data = []; while( value <= momentumMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( value, mass ) ); value += momentumStep; } return data; }, /** * The public function to calculate an array of velocity values by varying the mass. * You can reference it in your code as "Equations.Momentum.calcVelocityVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each velocity value. */ calcVelocityVsMass: function( massMin, massMax, massStep, momentum, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( momentum, value ) ); value += massStep; } return data; } }; }()); // Execute the function immediately /** * Force */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates force. */ var calcForceImpl = function( mass, acceleration ) { // f = ma mass = 1.0 * mass; acceleration = 1.0 * acceleration; return mass*acceleration; }; /** * Private function that calculates mass. */ var calcMassImpl = function( acceleration, force ) { // m = F/a force = 1.0 * force; acceleration = 1.0 * acceleration; return force / acceleration; }; /** * Private function that calculates acceleration. */ var calcAccelerationImpl = function( force, mass ) { // a = F/m force = 1.0 * force; mass = 1.0 * mass; return force/mass; }; /** * This public object contains functions for Force. * You can reference it in your code as "Equations.Force". */ module.Force = { type: "force", version: "1.0", title: "Force", desc: "These calculators can be used to generate data using mass, acceleration and force.", /** * The public function to calculate force. * You can reference it in your code as "Equations.Force.calcForce( ... )". */ calcForce: calcForceImpl, /** * The public function to calculate an array of force values by varying the mass. * You can reference it in your code as "Equations.Force.calcForceVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each force value. */ calcForceVsMass: function( massMin, massMax, massStep, acceleration, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcForceImpl( value, acceleration ) ); value += massStep; } return data; }, /** * The public function to calculate an array of force values by varying the acceleration. * You can reference it in your code as "Equations.Force.calcForceVsAcceleration( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the acceleration value for each force value. */ calcForceVsAcceleration: function( accelerationMin, accelerationMax, accelerationStep, mass, labels ) { var value = accelerationMin; var data = []; while( value <= accelerationMax ) { if( labels ) { labels.push( value ); } data.push( calcForceImpl( mass, value ) ); value += accelerationStep; } return data; }, /** * The public function to calculate mass. * You can reference it in your code as "Equations.Force.calcMass( ... )". */ calcMass: calcMassImpl, /** * The public function to calculate an array of mass values by varying the acceleration. * You can reference it in your code as "Equations.Force.calcMassVsAcceleration( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the acceleration value for each mass value. */ calcMassVsAcceleration: function( accelerationMin, accelerationMax, accelerationStep, force, labels ) { var value = accelerationMin; var data = []; while( value <= accelerationMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( value, force ) ); value += accelerationStep; } return data; }, /** * The public function to calculate an array of mass values by varying the force. * You can reference it in your code as "Equations.Force.calcMassVsForce( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the force value for each mass value. */ calcMassVsForce: function( forceMin, forceMax, forceStep, acceleration, labels ) { var value = forceMin; var data = []; while( value <= forceMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( acceleration, value ) ); value += forceStep; } return data; }, /** * The public function to calculate acceleration. * You can reference it in your code as "Equations.Force.calcAcceleration( ... )". */ calcAcceleration: calcAccelerationImpl, /** * The public function to calculate an array of acceleration values by varying the force. * You can reference it in your code as "Equations.Force.calcAccelerationVsForce( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the force value for each acceleration value. */ calcAccelerationVsForce: function( forceMin, forceMax, forceStep, mass, labels ) { var value = forceMin; var data = []; while( value <= forceMax ) { if( labels ) { labels.push( value ); } data.push( calcAccelerationImpl( value, mass ) ); value += forceStep; } return data; }, /** * The public function to calculate an array of acceleration values by varying the mass. * You can reference it in your code as "Equations.Force.calcAccelerationVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each acceleration value. */ calcAccelerationVsMass: function( massMin, massMax, massStep, force, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcAccelerationImpl( force, value ) ); value += massStep; } return data; } }; }()); // Execute the function immediately /** * Work */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates work. */ var calcWorkImpl = function( force, distance, angle ) { // W = Fdcos(A) force = 1.0 * force; distance = 1.0 * distance; angle = 1.0 * angle; return force*distance*Math.cos( angle ); }; /** * Private function that calculates force. */ var calcForceImpl = function( work, distance, angle ) { // F = W/dcos(A) work = 1.0 * work; distance = 1.0 * distance; angle = 1.0 * angle; return work / ( distance * Math.cos( angle ) ); }; /** * Private function that calculates distance. */ var calcDistanceImpl = function( work, force, angle ) { // d = W/Fcos(A) work = 1.0 * work; force = 1.0 * force; angle = 1.0 * angle; return work / ( force*Math.cos( angle ) ); }; /** * Private function that calculates angle. */ var calcAngleImpl = function( work, force, distance ) { // A = arccos(W/Fd) work = 1.0 * work; force = 1.0 * force; distance = 1.0 * distance; return Math.acos( work/( force*distance ) ); }; /** * This public object contains functions for Work. * You can reference it in your code as "Equations.Work". */ module.Work = { type: "work", version: "1.0", title: "Work", desc: "These calculators can be used to generate data using force, distance, angle and work.", /** * The public function to calculate work. * You can reference it in your code as "Equations.Work.calcWork( ... )". */ calcWork: calcWorkImpl, /** * The public function to calculate an array of work values by varying the force. * You can reference it in your code as "Equations.Work.calcWorkVsForce( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the force value for each work value. */ calcWorkVsForce: function( forceMin, forceMax, forceStep, distance, angle, labels ) { var value = forceMin; var data = []; while( value <= forceMax ) { if( labels ) { labels.push( value ); } data.push( calcWorkImpl( value, distance, angle ) ); value += forceStep; } return data; }, /** * The public function to calculate an array of work values by varying the distance. * You can reference it in your code as "Equations.Work.calcWorkVsDistance( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the distance value for each work value. */ calcWorkVsDistance: function( distanceMin, distanceMax, distanceStep, force, angle, labels ) { var value = distanceMin; var data = []; while( value <= distanceMax ) { if( labels ) { labels.push( value ); } data.push( calcWorkImpl( force, value, angle ) ); value += distanceStep; } return data; }, /** * The public function to calculate an array of work values by varying the angle. * You can reference it in your code as "Equations.Work.calcWorkVsAngle( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the angle value for each work value. */ calcWorkVsAngle: function( angleMin, angleMax, angleStep, force, distance, labels ) { var value = angleMin; var data = []; while( value <= angleMax ) { if( labels ) { labels.push( value ); } data.push( calcWorkImpl( force, distance, value ) ); value += angleStep; } return data; }, /** * The public function to calculate force. * You can reference it in your code as "Equations.Work.calcForce( ... )". */ calcForce: calcForceImpl, /** * The public function to calculate an array of force values by varying the work. * You can reference it in your code as "Equations.Work.calcForceVsWork( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the work value for each force value. */ calcForceVsWork: function( workMin, workMax, workStep, distance, angle, labels ) { var value = workMin; var data = []; while( value <= workMax ) { if( labels ) { labels.push( value ); } data.push( calcForceImpl( value, distance, angle ) ); value += workStep; } return data; }, /** * The public function to calculate an array of force values by varying the distance. * You can reference it in your code as "Equations.Work.calcForceVsDistance( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the distance value for each force value. */ calcForceVsDistance: function( distanceMin, distanceMax, distanceStep, work, angle, labels ) { var value = distanceMin; var data = []; while( value <= distanceMax ) { if( labels ) { labels.push( value ); } data.push( calcForceImpl( work, value, angle ) ); value += distanceStep; } return data; }, /** * The public function to calculate an array of force values by varying the angle. * You can reference it in your code as "Equations.Work.calcForceVsAngle( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the angle value for each force value. */ calcForceVsAngle: function( angleMin, angleMax, angleStep, work, distance, labels ) { var value = angleMin; var data = []; while( value <= angleMax ) { if( labels ) { labels.push( value ); } data.push( calcForceImpl( work, distance, value ) ); value += angleStep; } return data; }, /** * The public function to calculate distance. * You can reference it in your code as "Equations.Work.calcDistance( ... )". */ calcDistance: calcDistanceImpl, /** * The public function to calculate an array of distance values by varying the work. * You can reference it in your code as "Equations.Work.calcDistanceVsWork( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the work value for each distance value. */ calcDistanceVsWork: function( workMin, workMax, workStep, force, angle, labels ) { var value = workMin; var data = []; while( value <= workMax ) { if( labels ) { labels.push( value ); } data.push( calcDistanceImpl( value, force, angle ) ); value += workStep; } return data; }, /** * The public function to calculate an array of distance values by varying the force. * You can reference it in your code as "Equations.Work.calcDistanceVsForce( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the force value for each distance value. */ calcDistanceVsForce: function( forceMin, forceMax, forceStep, work, angle, labels ) { var value = forceMin; var data = []; while( value <= forceMax ) { if( labels ) { labels.push( value ); } data.push( calcDistanceImpl( work, value, angle ) ); value += forceStep; } return data; }, /** * The public function to calculate an array of distance values by varying the angle. * You can reference it in your code as "Equations.Work.calcDistanceVsAngle( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the angle value for each distance value. */ calcDistanceVsAngle: function( angleMin, angleMax, angleStep, work, force, labels ) { var value = angleMin; var data = []; while( value <= angleMax ) { if( labels ) { labels.push( value ); } data.push( calcDistanceImpl( work, force, value ) ); value += angleStep; } return data; }, /** * The public function to calculate angle. * You can reference it in your code as "Equations.Work.calcAngle( ... )". */ calcAngle: calcAngleImpl, /** * The public function to calculate an array of angle values by varying the work. * You can reference it in your code as "Equations.Work.calcAngleVsWork( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the work value for each angle value. */ calcAngleVsWork: function( workMin, workMax, workStep, force, distance, labels ) { var value = workMin; var data = []; while( value <= workMax ) { if( labels ) { labels.push( value ); } data.push( calcAngleImpl( value, force, distance ) ); value += workStep; } return data; }, /** * The public function to calculate an array of angle values by varying the force. * You can reference it in your code as "Equations.Work.calcAngleVsForce( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the force value for each angle value. */ calcAngleVsForce: function( forceMin, forceMax, forceStep, work, distance, labels ) { var value = forceMin; var data = []; while( value <= forceMax ) { if( labels ) { labels.push( value ); } data.push( calcAngleImpl( work, value, distance ) ); value += forceStep; } return data; }, /** * The public function to calculate an array of angle values by varying the distance. * You can reference it in your code as "Equations.Work.calcAngleVsDistance( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the distance value for each angle value. */ calcAngleVsDistance: function( distanceMin, distanceMax, distanceStep, work, force, labels ) { var value = distanceMin; var data = []; while( value <= distanceMax ) { if( labels ) { labels.push( value ); } data.push( calcAngleImpl( work, force, value ) ); value += distanceStep; } return data; } }; }()); // Execute the function immediately /** * Energy */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates energy. */ var calcEnergyImpl = function( mass, velocity ) { // e = mv^2 mass = 1.0 * mass; velocity = 1.0 * velocity; return mass*velocity*velocity; }; /** * Private function that calculates mass. */ var calcMassImpl = function( energy, velocity ) { // m = e/v^2 energy = 1.0 * energy; velocity = 1.0 * velocity; return energy / (velocity * velocity); }; /** * Private function that calculates velocity. */ var calcVelocityImpl = function( mass, energy ) { // v = sqrt(e/m) mass = 1.0 * mass; energy = 1.0 * energy; return Math.sqrt( energy / mass ); }; /** * This public object contains functions for Energy. * You can reference it in your code as "Equations.Energy". */ module.Energy = { type: "energy", version: "1.0", title: "Energy", desc: "These calculators can be used to generate data using mass, velocity and energy.", /** * The public function to calculate energy. * You can reference it in your code as "Equations.Energy.calcEnergy( ... )". */ calcEnergy: calcEnergyImpl, /** * The public function to calculate an array of energy values by varying the mass. * You can reference it in your code as "Equations.Energy.calcEnergyVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each energy value. */ calcEnergyVsMass: function( massMin, massMax, massStep, velocity, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcEnergyImpl( value, velocity ) ); value += massStep; } return data; }, /** * The public function to calculate an array of energy values by varying the velocity. * You can reference it in your code as "Equations.Energy.calcEnergyVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each energy value. */ calcEnergyVsVelocity: function( velocityMin, velocityMax, velocityStep, mass, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcEnergyImpl( mass, value ) ); value += velocityStep; } return data; }, /** * The public function to calculate mass. * You can reference it in your code as "Equations.Energy.calcMass( ... )". */ calcMass: calcMassImpl, /** * The public function to calculate an array of mass values by varying the energy. * You can reference it in your code as "Equations.Energy.calcMassVsEnergy( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the energy value for each mass value. */ calcMassVsEnergy: function( energyMin, energyMax, energyStep, velocity, labels ) { var value = energyMin; var data = []; while( value <= energyMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( value, velocity ) ); value += energyStep; } return data; }, /** * The public function to calculate an array of mass values by varying the velocity. * You can reference it in your code as "Equations.Energy.calcMassVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each mass value. */ calcMassVsVelocity: function( velocityMin, velocityMax, velocityStep, energy, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( energy, value ) ); value += velocityStep; } return data; }, /** * The public function to calculate velocity. * You can reference it in your code as "Equations.Energy.calcVelocity( ... )". */ calcVelocity: calcVelocityImpl, /** * The public function to calculate an array of velocity values by varying the mass. * You can reference it in your code as "Equations.Energy.calcVelocityVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each velocity value. */ calcVelocityVsMass: function( massMin, massMax, massStep, energy, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( value, energy ) ); value += massStep; } return data; }, /** * The public function to calculate an array of velocity values by varying the energy. * You can reference it in your code as "Equations.Energy.calcVelocityVsEnergy( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the energy value for each velocity value. */ calcVelocityVsEnergy: function( energyMin, energyMax, energyStep, mass, labels ) { var value = energyMin; var data = []; while( value <= energyMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( mass, value ) ); value += energyStep; } return data; } }; }()); // Execute the function immediately /** * Kinetic Energy */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates energy. */ var calcEnergyImpl = function( mass, velocity ) { // K = mv^2 / 2 mass = 1.0 * mass; velocity = 1.0 * velocity; return mass*velocity*velocity/2.0; }; /** * Private function that calculates mass. */ var calcMassImpl = function( energy, velocity ) { // m = 2K/v^2 energy = 1.0 * energy; velocity = 1.0 * velocity; return 2.0 * energy / (velocity * velocity); }; /** * Private function that calculates velocity. */ var calcVelocityImpl = function( mass, energy ) { // v = sqrt(2K/m) mass = 1.0 * mass; energy = 1.0 * energy; return Math.sqrt( 2.0 * energy / mass ); }; /** * This public object contains functions for Kinetic Energy. * You can reference it in your code as "Equations.KineticEnergy". */ module.KineticEnergy = { type: "kinetic_energy", version: "1.0", title: "Kinetic Energy", desc: "These calculators can be used to generate data using mass, velocity and energy.", /** * The public function to calculate energy. * You can reference it in your code as "Equations.KineticEnergy.calcEnergy( ... )". */ calcEnergy: calcEnergyImpl, /** * The public function to calculate an array of energy values by varying the mass. * You can reference it in your code as "Equations.KineticEnergy.calcEnergyVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each energy value. */ calcEnergyVsMass: function( massMin, massMax, massStep, velocity, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcEnergyImpl( value, velocity ) ); value += massStep; } return data; }, /** * The public function to calculate an array of energy values by varying the velocity. * You can reference it in your code as "Equations.KineticEnergy.calcEnergyVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each energy value. */ calcEnergyVsVelocity: function( velocityMin, velocityMax, velocityStep, mass, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcEnergyImpl( mass, value ) ); value += velocityStep; } return data; }, /** * The public function to calculate mass. * You can reference it in your code as "Equations.KineticEnergy.calcMass( ... )". */ calcMass: calcMassImpl, /** * The public function to calculate an array of mass values by varying the energy. * You can reference it in your code as "Equations.KineticEnergy.calcMassVsEnergy( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the energy value for each mass value. */ calcMassVsEnergy: function( energyMin, energyMax, energyStep, velocity, labels ) { var value = energyMin; var data = []; while( value <= energyMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( value, velocity ) ); value += energyStep; } return data; }, /** * The public function to calculate an array of mass values by varying the velocity. * You can reference it in your code as "Equations.KineticEnergy.calcMassVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each mass value. */ calcMassVsVelocity: function( velocityMin, velocityMax, velocityStep, energy, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcMassImpl( energy, value ) ); value += velocityStep; } return data; }, /** * The public function to calculate velocity. * You can reference it in your code as "Equations.KineticEnergy.calcVelocity( ... )". */ calcVelocity: calcVelocityImpl, /** * The public function to calculate an array of velocity values by varying the mass. * You can reference it in your code as "Equations.KineticEnergy.calcVelocityVsMass( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the mass value for each velocity value. */ calcVelocityVsMass: function( massMin, massMax, massStep, energy, labels ) { var value = massMin; var data = []; while( value <= massMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( value, energy ) ); value += massStep; } return data; }, /** * The public function to calculate an array of velocity values by varying the energy. * You can reference it in your code as "Equations.KineticEnergy.calcVelocityVsEnergy( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the energy value for each velocity value. */ calcVelocityVsEnergy: function( energyMin, energyMax, energyStep, mass, labels ) { var value = energyMin; var data = []; while( value <= energyMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( mass, value ) ); value += energyStep; } return data; } }; }()); // Execute the function immediately return module; }());