Ou, seguinte tem 3 método um que desenha um função seno, coseno e tangente, estou precisando agora fazer o gráfico da secante, cosecante e da cotangente, abaixo segue os códigos
private void drawCos(Graphics2D g2D) {
g2D.drawString("Sine Wave", 250, 10); // Draw some text
g2D.drawString(" 100", 15, 95); // Draw some text
g2D.drawString(" 0", 15, 205); // Draw some text
g2D.drawString("-100", 15, 305); // Draw some text
g2D.drawLine(40, 200, 460, 200);
int old_x = 50;
int old_y = 50;
int new_x = 50;
int new_y = 300;
for (int i = 1; i <= 100; i++) {
old_x = new_x;
old_y = new_y;
new_x += 4;
new_y = (int) (((Math.cos(((2 * Math.PI) / 100.0) * i)) * -100) + 200.0);
System.out.println("From: " + old_x + ", " + old_y + " To: "
+ new_x + ", " + new_y);
g2D.drawLine(old_x, old_y, new_x, new_y );
}
}
private void drawSin(Graphics2D g2D) {
g2D.drawString("Sine Wave", 250, 10); // Draw some text
g2D.drawString(" 100", 15, 95); // Draw some text
g2D.drawString(" 0", 15, 205); // Draw some text
g2D.drawString("-100", 15, 305); // Draw some text
g2D.drawLine(40, 200, 460, 200);
int old_x = 50;
int old_y = 200;
int new_x = 50;
int new_y = 200;
for (int i = 1; i <= 100; i++) {
old_x = new_x;
old_y = new_y;
new_x += 4;
new_y = (int) (((Math.sin(((2 * Math.PI) / 100.0) * i)) * -100) + 200.0);
System.out.println("From: " + old_x + ", " + old_y + " To: "
+ new_x + ", " + new_y);
g2D.drawLine(old_x, old_y, new_x, new_y);
}
}
private void drawTan(Graphics2D g2D){
g2D.drawString("Sine Wave", 250, 10); // Draw some text
g2D.drawString(" 100", 15, 95); // Draw some text
g2D.drawString(" 0", 15, 205); // Draw some text
g2D.drawString("-100", 15, 305); // Draw some text
g2D.drawLine(40, 200, 460, 200);
g2D.drawLine(50, 50, 50, 350);
int old_x = 50;
int old_y = 200;
int new_x = 50;
int new_y = 200;
for (int i = 1; i <= 100; i++) {
old_x = new_x;
old_y = new_y;
new_x += 4;
new_y = (int) (((Math.tan(((2 * Math.PI) / 100.0) * i)) * -10) + 200.0);
System.out.println("From: " + old_x + ", " + old_y + " To: "
+ new_x + ", " + new_y);
g2D.drawLine(old_x, old_y, new_x, new_y);
}
}
Alguem tem alguma ideia de como posso fazer ??