Avatar of Mike Eghtebas
Mike Eghtebas
Flag for United States of America asked on

Animation help 3

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)));
      }
  }
}

Open in new window

drum-final.png
Scripting LanguagesJava

Avatar of undefined
Last Comment
rrz

8/22/2022 - Mon
HainKurt

ok, whats the question :)
Mike Eghtebas

ASKER
Question: Could you make animation in JApplet or in a java desktop to perform (animate( this operation.

Mike Eghtebas

ASKER
I am new to java and this will be a great start for me to learn more about animation. Also this is not school work.

mike
Your help has saved me hundreds of hours of internet surfing.
fblack61
Mike Eghtebas

ASKER
Also, FYI, the above code is from rrz@871311 who has been helping me on this in last few questions in math and java TA.
HainKurt

have a look at these sample codes :)

http://java.sun.com/products/java-media/2D/samples/suite/
ASKER CERTIFIED SOLUTION
rrz

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mike Eghtebas

ASKER
Amazing. Thank you very much.

Mike
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mike Eghtebas

ASKER
phoffric

Very nice, rrz. Good working with you.
Mike Eghtebas

ASKER
Paul, Thanks to your valuable contribution as well,


regards,

Mike
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
phoffric

You're welcome. Interesting project. Hope to see your actual cam when you complete it.
rrz

Thanks for the points.

Thanks, phoffric.