/* * Generated by www.nevyns-lab.com on 2019-08-23T07:55:00+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 = {}; /** * Velocity */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates velocity. */ var calcVelocityImpl = function( distance, time ) { // v = d/t distance = 1.0 * distance; time = 1.0 * time; return distance/time; }; /** * Private function that calculates distance. */ var calcDistanceImpl = function( velocity, time ) { // d = vt velocity = 1.0 * velocity; time = 1.0 * time; return velocity * time; }; /** * Private function that calculates time. */ var calcTimeImpl = function( distance, velocity ) { // t = d/v distance = 1.0 * distance; velocity = 1.0 * velocity; return distance/velocity; }; /** * This public object contains functions for Velocity. * You can reference it in your code as "Equations.Velocity". */ module.Velocity = { type: "velocity", version: "1.0", title: "Velocity", desc: "These calculators can be used to generate data using distance, time and velocity.", /** * The public function to calculate velocity. * You can reference it in your code as "Equations.Velocity.calcVelocity( ... )". */ calcVelocity: calcVelocityImpl, /** * The public function to calculate an array of velocity values by varying the distance. * You can reference it in your code as "Equations.Velocity.calcVelocityVsDistance( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the distance value for each velocity value. */ calcVelocityVsDistance: function( distanceMin, distanceMax, distanceStep, time, labels ) { var value = distanceMin; var data = []; while( value <= distanceMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( value, time ) ); value += distanceStep; } return data; }, /** * The public function to calculate an array of velocity values by varying the time. * You can reference it in your code as "Equations.Velocity.calcVelocityVsTime( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the time value for each velocity value. */ calcVelocityVsTime: function( timeMin, timeMax, timeStep, distance, labels ) { var value = timeMin; var data = []; while( value <= timeMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( distance, value ) ); value += timeStep; } return data; }, /** * The public function to calculate distance. * You can reference it in your code as "Equations.Velocity.calcDistance( ... )". */ calcDistance: calcDistanceImpl, /** * The public function to calculate an array of distance values by varying the velocity. * You can reference it in your code as "Equations.Velocity.calcDistanceVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each distance value. */ calcDistanceVsVelocity: function( velocityMin, velocityMax, velocityStep, time, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcDistanceImpl( value, time ) ); value += velocityStep; } return data; }, /** * The public function to calculate an array of distance values by varying the time. * You can reference it in your code as "Equations.Velocity.calcDistanceVsTime( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the time value for each distance value. */ calcDistanceVsTime: function( timeMin, timeMax, timeStep, velocity, labels ) { var value = timeMin; var data = []; while( value <= timeMax ) { if( labels ) { labels.push( value ); } data.push( calcDistanceImpl( velocity, value ) ); value += timeStep; } return data; }, /** * The public function to calculate time. * You can reference it in your code as "Equations.Velocity.calcTime( ... )". */ calcTime: calcTimeImpl, /** * The public function to calculate an array of time values by varying the distance. * You can reference it in your code as "Equations.Velocity.calcTimeVsDistance( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the distance value for each time value. */ calcTimeVsDistance: function( distanceMin, distanceMax, distanceStep, velocity, labels ) { var value = distanceMin; var data = []; while( value <= distanceMax ) { if( labels ) { labels.push( value ); } data.push( calcTimeImpl( value, velocity ) ); value += distanceStep; } return data; }, /** * The public function to calculate an array of time values by varying the velocity. * You can reference it in your code as "Equations.Velocity.calcTimeVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each time value. */ calcTimeVsVelocity: function( velocityMin, velocityMax, velocityStep, distance, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcTimeImpl( distance, value ) ); value += velocityStep; } return data; } }; }()); // Execute the function immediately /** * Acceleration */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates acceleration. */ var calcAccelerationImpl = function( velocity, time ) { // a = v/t velocity = 1.0 * velocity; time = 1.0 * time; return velocity/time; }; /** * Private function that calculates velocity. */ var calcVelocityImpl = function( acceleration, time ) { // v = at acceleration = 1.0 * acceleration; time = 1.0 * time; return acceleration * time; }; /** * Private function that calculates time. */ var calcTimeImpl = function( velocity, acceleration ) { // t = v/a velocity = 1.0 * velocity; acceleration = 1.0 * acceleration; return velocity/acceleration; }; /** * This public object contains functions for Acceleration. * You can reference it in your code as "Equations.Acceleration". */ module.Acceleration = { type: "acceleration", version: "1.0", title: "Acceleration", desc: "These calculators can be used to generate data using velocity, time and acceleration.", /** * The public function to calculate acceleration. * You can reference it in your code as "Equations.Acceleration.calcAcceleration( ... )". */ calcAcceleration: calcAccelerationImpl, /** * The public function to calculate an array of acceleration values by varying the velocity. * You can reference it in your code as "Equations.Acceleration.calcAccelerationVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each acceleration value. */ calcAccelerationVsVelocity: function( velocityMin, velocityMax, velocityStep, time, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcAccelerationImpl( value, time ) ); value += velocityStep; } return data; }, /** * The public function to calculate an array of acceleration values by varying the time. * You can reference it in your code as "Equations.Acceleration.calcAccelerationVsTime( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the time value for each acceleration value. */ calcAccelerationVsTime: function( timeMin, timeMax, timeStep, velocity, labels ) { var value = timeMin; var data = []; while( value <= timeMax ) { if( labels ) { labels.push( value ); } data.push( calcAccelerationImpl( velocity, value ) ); value += timeStep; } return data; }, /** * The public function to calculate velocity. * You can reference it in your code as "Equations.Acceleration.calcVelocity( ... )". */ calcVelocity: calcVelocityImpl, /** * The public function to calculate an array of velocity values by varying the acceleration. * You can reference it in your code as "Equations.Acceleration.calcVelocityVsAcceleration( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the acceleration value for each velocity value. */ calcVelocityVsAcceleration: function( accelerationMin, accelerationMax, accelerationStep, time, labels ) { var value = accelerationMin; var data = []; while( value <= accelerationMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( value, time ) ); value += accelerationStep; } return data; }, /** * The public function to calculate an array of velocity values by varying the time. * You can reference it in your code as "Equations.Acceleration.calcVelocityVsTime( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the time value for each velocity value. */ calcVelocityVsTime: function( timeMin, timeMax, timeStep, acceleration, labels ) { var value = timeMin; var data = []; while( value <= timeMax ) { if( labels ) { labels.push( value ); } data.push( calcVelocityImpl( acceleration, value ) ); value += timeStep; } return data; }, /** * The public function to calculate time. * You can reference it in your code as "Equations.Acceleration.calcTime( ... )". */ calcTime: calcTimeImpl, /** * The public function to calculate an array of time values by varying the velocity. * You can reference it in your code as "Equations.Acceleration.calcTimeVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each time value. */ calcTimeVsVelocity: function( velocityMin, velocityMax, velocityStep, acceleration, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcTimeImpl( value, acceleration ) ); value += velocityStep; } return data; }, /** * The public function to calculate an array of time values by varying the acceleration. * You can reference it in your code as "Equations.Acceleration.calcTimeVsAcceleration( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the acceleration value for each time value. */ calcTimeVsAcceleration: function( accelerationMin, accelerationMax, accelerationStep, velocity, labels ) { var value = accelerationMin; var data = []; while( value <= accelerationMax ) { if( labels ) { labels.push( value ); } data.push( calcTimeImpl( velocity, value ) ); value += accelerationStep; } return data; } }; }()); // Execute the function immediately return module; }());