package com.nevynslab.math; /* * Generated by www.nevyns-lab.com on 2019-05-21T14:44:03+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. * */ import java.util.List; import java.util.ArrayList; /** * This class contains inner classes that each provide methods for an equation. */ public class Equations { /** * This class provides methods for the Angle Velocity equation. */ public static class AngleVelocity { public static final String TYPE = "angle_velocity"; public static final String VERSION = "1.0"; public static final String TITLE = "Angle Velocity"; public static final String DESCRIPTION = "These calculators can be used to generate data using radius, tangential velocity and angle velocity."; /** * Public method that calculates radius. * You can reference it in your code as "Equations.AngleVelocity.calcRadius( ... )". */ public static double calcRadius(double velocity, double angle) { // r = 2 * PIg^2 * v / sqrt( a^4 * PIk^4 + 4 * a^2 * PIk^2 * PIg^2 ) double a2 = 1.0 * angle * angle; double pi2 = Math.PI * Math.PI; return 2 * pi2 * velocity / Math.sqrt( a2 * a2 * 256.0 + 4.0 * a2 * 16.0 * pi2 ); } /** * The public method to calculate a list of radius values by varying the velocity. * You can reference it in your code as "Equations.AngleVelocity.calcRadiusVsVelocity( ... )". * The data parameter can be null and a new list will be created and returned. * The labels parameter can be null. If supplied, it will be populated with * the velocity value for each radius value. */ public static List calcRadiusVsVelocity(double velocityMin, double velocityMax, double velocityStep, double angle, List data, List labels) { double value = velocityMin; if( data == null ) { data = new ArrayList(); } while( value <= velocityMax ) { if( labels != null ) { labels.add( value ); } data.add( calcRadius( value, angle ) ); value += velocityStep; } return data; } /** * The public method to calculate a list of radius values by varying the angle. * You can reference it in your code as "Equations.AngleVelocity.calcRadiusVsAngle( ... )". * The data parameter can be null and a new list will be created and returned. * The labels parameter can be null. If supplied, it will be populated with * the angle value for each radius value. */ public static List calcRadiusVsAngle(double angleMin, double angleMax, double angleStep, double velocity, List data, List labels) { double value = angleMin; if( data == null ) { data = new ArrayList(); } while( value <= angleMax ) { if( labels != null ) { labels.add( value ); } data.add( calcRadius( velocity, value ) ); value += angleStep; } return data; } } }