package com.nevynslab.math; /* * Generated by www.nevyns-lab.com on 2019-05-21T14:55:52+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 angle. * You can reference it in your code as "Equations.AngleVelocity.calcAngle( ... )". */ public static double calcAngle(double radius, double velocity) { // a = PIg * sqrt( 2 * r * sqrt( v^2 + r^2 ) - 2 * r^2 ) / (PIk*r) double r2 = radius * radius; double v2 = velocity * velocity; double omega = Math.sqrt( ( 2 * radius * Math.sqrt( v2 + r2 ) ) - 2 * r2 ); return Math.PI * omega / ( 4 * radius ); } /** * The public method to calculate a list of angle values by varying the radius. * You can reference it in your code as "Equations.AngleVelocity.calcAngleVsRadius( ... )". * 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 angle value. */ public static List calcAngleVsRadius(double radiusMin, double radiusMax, double radiusStep, double velocity, List data, List labels) { double value = radiusMin; if( data == null ) { data = new ArrayList(); } while( value <= radiusMax ) { if( labels != null ) { labels.add( value ); } data.add( calcAngle( value, velocity ) ); value += radiusStep; } return data; } /** * The public method to calculate a list of angle values by varying the velocity. * You can reference it in your code as "Equations.AngleVelocity.calcAngleVsVelocity( ... )". * 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 angle value. */ public static List calcAngleVsVelocity(double velocityMin, double velocityMax, double velocityStep, double radius, List data, List labels) { double value = velocityMin; if( data == null ) { data = new ArrayList(); } while( value <= velocityMax ) { if( labels != null ) { labels.add( value ); } data.add( calcAngle( radius, value ) ); value += velocityStep; } return data; } } }