/* * Generated by www.nevyns-lab.com on 2019-05-21T15:26:30+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 = {}; /** * Angle Velocity */ (function() // Create a closure to avoid function name collisions { /** * Private function that calculates radius. */ var calcRadiusImpl = function( velocity, angle ) { // r = 2 * PIg^2 * v / sqrt( a^4 * PIk^4 + 4 * a^2 * PIk^2 * PIg^2 ) var a2 = 1.0 * angle * angle; var pi2 = Math.PI * Math.PI; return 2 * pi2 * velocity / Math.sqrt( a2 * a2 * 256.0 + 4.0 * a2 * 16 * pi2 ); }; /** * This public object contains functions for Angle Velocity. * You can reference it in your code as "Equations.AngleVelocity". */ module.AngleVelocity = { type: "angle_velocity", version: "1.0", title: "Angle Velocity", desc: "These calculators can be used to generate data using radius, tangential velocity and angle velocity.", /** * The public function to calculate radius. * You can reference it in your code as "Equations.AngleVelocity.calcRadius( ... )". */ calcRadius: calcRadiusImpl, /** * The public function to calculate an array of radius values by varying the velocity. * You can reference it in your code as "Equations.AngleVelocity.calcRadiusVsVelocity( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the velocity value for each radius value. */ calcRadiusVsVelocity: function( velocityMin, velocityMax, velocityStep, angle, labels ) { var value = velocityMin; var data = []; while( value <= velocityMax ) { if( labels ) { labels.push( value ); } data.push( calcRadiusImpl( value, angle ) ); value += velocityStep; } return data; }, /** * The public function to calculate an array of radius values by varying the angle. * You can reference it in your code as "Equations.AngleVelocity.calcRadiusVsAngle( ... )". * The labels parameter is optional. If supplied, it must be an array and will be * populated with the angle value for each radius value. */ calcRadiusVsAngle: function( angleMin, angleMax, angleStep, velocity, labels ) { var value = angleMin; var data = []; while( value <= angleMax ) { if( labels ) { labels.push( value ); } data.push( calcRadiusImpl( velocity, value ) ); value += angleStep; } return data; } }; }()); // Execute the function immediately return module; }());