Hallo,
habe ein Programm geschrieben, was eine Zeichnung ausgibt.
Der innere Teil soll durch betätigen eines Buttons um einen beliebig festgelegten Winkel (z.B.30°) gedreht werden.
Hat jemand eine Idee wie ich an das Problem rangehen kann.
Mein Programm sieht wie folgt aus
Der Teil ab Zeile 193 ist der sich drehen soll.
Wäre auch schon hilfreich, wenn es eine Funktion gibt, die alle 5 Sekunden oder so um einen Winkel dreht.
Danke schonma vorab.
Tschau Marcel
habe ein Programm geschrieben, was eine Zeichnung ausgibt.
Der innere Teil soll durch betätigen eines Buttons um einen beliebig festgelegten Winkel (z.B.30°) gedreht werden.
Hat jemand eine Idee wie ich an das Problem rangehen kann.
Mein Programm sieht wie folgt aus
Java:
import java.applet.*;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.math.*;
import javax.swing.JButton;
public class asynchron extends Applet {
int width, height;
public void init() {
width = getSize().width;
height = getSize().height;
setBackground( Color.white );
}
public void parameter (){
//Einführung aller Parameter und Zuweisung zu einem Buchstaben (Verkürzung Quellcode)
// beta_Te_R = a; Rotor pole arc [°]
// double a = 17.5;
// beta_Te_S = b; Stator pole arc [°]
// double b = 15.5;
// c_Lam_R = g; Lamination factor of rotor [-]
// double g = 0.97;
// c_Lam_S = d; Lamination factor of Stator [-]
// double d = 0.97;
// c_Win = e; Cooper slot fill factor [-]
// double e = 0.5;
// delta_Gap = f; Air gap length [m]
// double f = 0.0003;
// h_Win = g; Height of the stator winding [m]
// double g = 0.02;
// l_Stk = h; Stack length of the machine [m]
// double h = 0.125;
// N_P_R = i; Number of rotor poles [-]
// int i = 8;
// N_P_S = j; Number of stator poles [-]
// int j = 12;
// N_Ph = k; Number of phases [-]
// int k = 3;
// N_Tp = l; Number of windings [-]
// int l = 10;
// r_0 = m; Radius from axis to bottom of rotor slot [m]
// double m = 0.027;
// r_1 = n; Radius from axis to surface of rotor [m]
// double n = 0.03395;
// r_2 = o; Radius from axis to inside of stator slot [m]
// double o = 0.0555;
// r_3 = p; Radius from axis to outside stator surface [m]
// double p = 0.06725;
// r_4 = q; Radius from axis to outside frame surface [m]
// double q = 0.073;
// r_Sh = r; Radius from axis to surface of shaft [m]
// double r = 0.012;
// r_Win = s; Radius from one winding [m]
// double s = 0.001504;
// w_Can_R = t; Width of the rotor can [m]
// double t = 0.0003;
// w_Can_S = u; Width of the stator can [m]
// double u = 0.0003;
// w_S1_Can_S = v; Width of stator slot to stator can [m]
// double v = 0.0023;
// w_Win = w; Width of the winding [m]
// double w = 0.004;
}
// Einführung der Drehfunktion (Math.toRadians (0)) hier 0°, um später nur mit dem
// Befehl aft = new AffineTransform() eine neue Drehfunktion einzuführen
public void paint (Graphics g){
Graphics2D g2d = (Graphics2D) g;
AffineTransform aft = new AffineTransform();
aft.rotate(Math.toRadians(0), 400, 350);
g2d.setTransform(aft);
//Der äußere graue Kreis wird im Maßstab 1m = 4000 Pixel gezeichnet
// r_3 = p; Radius from axis to outside stator surface [m]
double p = 0.06725;
// r_4 = q; Radius from axis to outside frame surface [m]
double q = 0.073;
g.setColor(Color.gray);
g.fillOval((int)(400-4000*q), (int) (350-4000*q),(int)(2*4000*q), (int)(2*4000*q));
g.setColor(Color.white);
g.fillOval((int)(400-4000*p), (int)(350-4000*p),(int)(2*4000*p),(int)(2*4000*p));
// Spaltrohre werden gezeichnet
// r_1 = n; Radius from axis to surface of rotor [m]
double n = 0.03395;
// w_Can_R = t; Width of the rotor can [m]
double t = 0.0003;
// w_Can_S = u; Width of the stator can [m]
double u = 0.0003;
// delta_Gap = f; //Air gap length [m]
double f = 0.0003;
//für Stator
double r_stator_innen = n+t+u+f;
g.setColor(Color.gray);
g.fillOval((int)(400-4000*(r_stator_innen)), (int) (350-4000*(r_stator_innen)),(int)(2*4000*(r_stator_innen)), (int)(2*4000*(r_stator_innen)));
g.setColor(Color.white);
g.fillOval((int)(400-4000*((r_stator_innen)-u)), (int) (350-4000*((r_stator_innen)-u)),(int)(2*4000*((r_stator_innen)-u)), (int)(2*4000*((r_stator_innen)-u)));
//für Rotor
g.setColor(Color.gray);
g.fillOval((int)(400-4000*n), (int) (350-4000*n),(int)(2*4000*n), (int)(2*4000*n));
g.setColor(Color.white);
g.fillOval((int)(400-4000*(n-t)), (int) (350-4000*(n-t)),(int)(2*4000*(n-t)), (int)(2*4000*(n-t)));
// Der Stator mit seinen Statorzähnen wird gezeichnet
// r_2 = o; Radius from axis to inside of stator slot [m]
double o = 0.0555;
g.setColor(Color.black);
g.drawOval((int)(400-4000*o), (int) (350-4000*o),(int)(2*4000*o), (int)(2*4000*o));
// N_P_S = j; Number of stator poles [-]
aft = new AffineTransform();
int j = 3;
for (int x=0; x<j; x++)
{
double stator = (360 / j) * x;
aft.rotate(Math.toRadians(stator), 400, 350);
g2d.setTransform(aft);
// Zeichnet die Wicklung um die Statorzähne
// beta_Te_S = b; Stator pole arc [°]
double b = 15.5;
// w_Win = w; Width of the winding [m]
double w = 0.004;
// h_Win = c; Height of the stator winding [m]
double c = 0.02;
g.setColor(Color.black);
g.drawRect((int)((400-((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen))-(int)(4000*w)), (int)(350-4000*o), (int)(4000*w), (int)(4000*c));
g.setColor(Color.black);
g.drawRect((int)(400+((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen)), (int)(350-4000*o), (int)(4000*w), (int)(4000*c));
g.setColor(Color.black);
g.drawOval((int)((400-((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen))-(int)(4000*w)), (int)(350-4000*o), 10, 10);
g.setColor(Color.black);
g.fillOval((int)(400+((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen)), (int)(350-4000*o), 10, 10);
//Statorzähne werden gezeichnet
g.setColor(Color.black);
g.drawRect((int)(400-((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen)), (int)(350-4000*o), (int)(2*((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen)), (int)(4000*(o-r_stator_innen)));
g.setColor(Color.white);
g.fillRect((int)(400-((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen))+1, (int)(350-4000*o)-5, (int)(2*((Math.sin (b* 3.1415/180.0))*4000*r_stator_innen))-2, (int)(4000*(o-r_stator_innen)));
// Der Rotor mit seinen Rotorzähnen wird gezeichnet
// N_P_R = i; Number of rotor poles [-]
// r_1 = n; Radius from axis to surface of rotor [m]
// double n = 0.03395;
// r_0 = m; Radius from axis to bottom of rotor slot [m]
double m = 0.027;
g.setColor(Color.black);
g.drawOval((int)(400-(4000*m)), (int) (350-4000*m),(int)(2*4000*m), (int)(2*4000*m));
aft = new AffineTransform();
int i = 5;
for (int y=0; y<i; y++)
{
double rotor = (360 / i) * y;
aft.rotate(Math.toRadians(rotor), 400, 350);
g2d.setTransform(aft);
// beta_Te_R = a; Rotor pole arc [°]
double a = 17.5;
g.setColor(Color.black);
g.drawRect((int)(400-((Math.sin (a* 3.1415/180.0))*4000*n)), (int)(350-4000*n), (int)(2*((Math.sin (a* 3.1415/180.0))*4000*n)), (int)(4000*(n-m)+10));
g.setColor(Color.white);
g.fillRect((int)(400-((Math.sin (a* 3.1415/180.0))*4000*n)+1), (int)(350-4000*n)+1, (int)(2*((Math.sin (a* 3.1415/180.0))*4000*n))-2, (int)(4000*(n-m))+5);
g.setColor(Color.white);
g.fillOval((int)(400-(4000*m)+1), (int) (350-4000*m)+1,(int)(2*4000*m)-1, (int)(2*4000*m)-1);
// einfügen der Drehfunktion, da sonst die letzten Kreise unnötig kopiert und gedreht werden
aft = new AffineTransform();
aft.rotate(Math.toRadians(0), 400, 350);
g2d.setTransform(aft);
// Der innere graue Kreis wird gezeichnet
// r_Sh = r; Radius from axis to surface of shaft [m]
double r = 0.012;
g.setColor(Color.gray);
g.fillOval((int)(400-(4000*r)), (int) (350-4000*r),(int)(2*4000*r), (int)(2*4000*r));
}
}
}
}
Der Teil ab Zeile 193 ist der sich drehen soll.
Wäre auch schon hilfreich, wenn es eine Funktion gibt, die alle 5 Sekunden oder so um einen Winkel dreht.
Danke schonma vorab.
Tschau Marcel