Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package slingshot3.pkg0;
- import java.util.*;
- import java.text.*;
- /**
- *
- * @author GFNVIDIA
- */
- public class Slingshot30 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- double y1 = 1.0;
- double x1 = 0.0;
- double gravity = 9.8;
- double dragCo = 0.40;
- double airDensity = 1.23;
- double CSArea = 0.00426;
- double baseballMass = 0.145;
- double velocity = 23.02;
- double angleNew = Math.toRadians(45.0);
- double totalDisplacement;
- double AR;
- double fricFX;
- double fricFY;
- double gravForce;
- double iniVeloYrads;
- double iniVeloXrads;
- double iniVeloYdeg;
- double iniVeloXdeg;
- double netForceX;
- double netForceY;
- double accelX;
- double accelY;
- double time;
- double finalVeloX;
- double finalVeloY;
- while (y1 > 0){
- //Double massInput = Double.parseDouble(txtMassInput.getText());
- //Double angleInput = Math.toRadians(Double.parseDouble(txtLaunchAngle.getText())); //this is to put degrees to radians... will later be converted back to degrees.
- //angleNew = Math.toRadians(45.0);
- totalDisplacement = 0.0;
- // program begins
- AR = 0.5*(gravity*dragCo*airDensity*CSArea*velocity*velocity);
- fricFX = AR*(Math.cos(angleNew));
- //fricFY = 0.0;
- if (angleNew > 0){
- fricFY = (-1)*AR*(Math.sin(angleNew));
- }
- else if (angleNew < 0){
- fricFY = AR*(Math.sin(angleNew));
- }
- else {
- fricFY = 0;
- }
- ///nonsense starts here
- iniVeloYrads = Math.toDegrees(Math.sin(angleNew)) * velocity;
- iniVeloXrads = Math.toDegrees(Math.cos(angleNew)) * velocity;
- // code is continued down here to convert the velocity with respect to degrees
- //iniVeloYdeg = Math.toDegrees(iniVeloYrads);
- //iniVeloXdeg = Math.toDegrees(iniVeloXrads);
- gravForce = (gravity*baseballMass)*(-1);
- netForceX = fricFX;
- netForceY = fricFY + gravForce;
- //continued
- accelX = netForceX/baseballMass;
- accelY = netForceY/baseballMass;
- time = 1/100;
- //continued
- finalVeloX = iniVeloXrads+(accelX*time);
- finalVeloY = iniVeloYrads+(accelY*time);
- velocity = Math.sqrt((finalVeloX*finalVeloX)+(finalVeloY*finalVeloY));
- x1 = x1 + (finalVeloX*time + 0.5*accelX*Math.pow(time,2));
- y1 = y1 + (finalVeloY*time + 0.5*accelY*Math.pow(time,2));
- //totalDisplacement = totalDisplacement+x1;
- angleNew = Math.toDegrees(Math.atan(finalVeloY/finalVeloX));
- System.out.println(y1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement