troubleshooting Question

# Animation help 3 asked on
JavaScripting Languages
As shown below, a circular drum with a string wrapped around it is pulled in x-direction. as a result:

1. The drum rotates (see angle a).
2. Point of drum-string separation (originally at 0 degrees) moves up along the drum surface (see angle b).

The program is to accept the following four variables:
r, h, x inch/sec rate, and max via number of Jtext controls. Upon click the animation to start pulling the string and rotating the drum to max X at the giving rate (inches/sec).

At start, the string is pulled from X=0. In the process of pull, the angle of drum rotation a will be displayed in degrees.

In order see the drum is rotating, we can rotate a redial line drawn from center of the drum to zero angle.

The equation producing the data is given in the attached java program.

Thank you.

The output:
x = 00.000 a = 00.000 b = 00.000
x = 50.000 a = 01.759 b = 00.667
x = 100.000 a = 05.498 b = 00.992
x = 150.000 a = 09.905 b = 01.153
x = 200.000 a = 14.571 b = 01.247
x = 250.000 a = 19.358 b = 01.307
x = 300.000 a = 24.212 b = 01.348
x = 350.000 a = 29.105 b = 01.378
.
.

``````import java.text.DecimalFormat;
public class Ax {
public static void main(String args[]) {
DecimalFormat df = new DecimalFormat("00.000");
double h = 60; //height of drum from base line
double r = 10; //drum radius
double k = r/h;
double j = 0;
double a = 0;
double C = 0; // equals cos(b)
for(double x = 0; x <= 1000; x += 50){
j = x/h;
C = (2*k*(j+k) + Math.sqrt(Math.pow(2*k*(j+k),2) - 4*(Math.pow(j+k,2) + 1)*(k*k - 1)))/(2*(Math.pow(j+k,2) + 1));
a = (r * Math.tan(Math.acos(C)) + h/C - h)/r - Math.acos(C);
System.out.println(" x = " + df.format(x) + " a = " + df.format(a) + " b = " + df.format(Math.acos(C)));
}
}
}
``````
drum-final.png
Join the community to see this answer!
###### Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.