package com.nevynslab.math; /* * Generated by www.nevyns-lab.com on 2019-05-21T15:18:50+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 velocity. * You can reference it in your code as "Equations.AngleVelocity.calcVelocity( ... )". */ public static double calcVelocity(double radius, double angle) { // v = a * PIk * r * sqrt( a^2 * PIk^2 + 4 * PIg^2 ) / 2 * PIg^2 return angle * 4 * radius * Math.sqrt( angle * angle * 16 + 4 * Math.PI * Math.PI ) / ( 2 * Math.PI * Math.PI ); } /** * The public method to calculate a list of velocity values by varying the radius. * You can reference it in your code as "Equations.AngleVelocity.calcVelocityVsRadius( ... )". * 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 radius value for each velocity value. */ public static List calcVelocityVsRadius(double radiusMin, double radiusMax, double radiusStep, double angle, List data, List labels) { double value = radiusMin; if( data == null ) { data = new ArrayList(); } while( value <= radiusMax ) { if( labels != null ) { labels.add( value ); } data.add( calcVelocity( value, angle ) ); value += radiusStep; } return data; } /** * The public method to calculate a list of velocity values by varying the angle. * You can reference it in your code as "Equations.AngleVelocity.calcVelocityVsAngle( ... )". * 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 velocity value. */ public static List calcVelocityVsAngle(double angleMin, double angleMax, double angleStep, double radius, List data, List labels) { double value = angleMin; if( data == null ) { data = new ArrayList(); } while( value <= angleMax ) { if( labels != null ) { labels.add( value ); } data.add( calcVelocity( radius, value ) ); value += angleStep; } return data; } } }