# Creating a Mathematical Curve in Java

• 01-16-2013, 08:34 AM
Zie_Mordecai
Creating a Mathematical Curve in Java
Hey I am having a problem of creating a Mathematical Curve that fits the sin(2x) or cos(2x) on a x and y axis regardless if it was negative or positive value. If it is possible or feasible may somebody help me out, I would deeply appreciate it.
• 01-16-2013, 09:00 AM
DarrylBurke
Re: Creating a Mathematical Curve in Java
Please go through the Forum Rules, particularly the second paragraph. I've merged the thread you started in New to Java here.

db
• 01-16-2013, 09:04 AM
DarrylBurke
Re: Creating a Mathematical Curve in Java
Quote:

Originally Posted by Zie_Mordecai
Hey I am having a problem of creating a Mathematical Curve that fits the sin(2x) or cos(2x) on a x and y axis regardless if it was negative or positive value. If it is possible or feasible may somebody help me out, I would deeply appreciate it.

To get help, you need to show what you've tried and explain how it doesn't meet your need, then ask a specific question. As it stands, this post looks like 'here's my assignment, someone please do it for me' -- and that isn't going to happen.

Are you familiar with the java.lang.Math class? Do you know how to perform custom painting? Have you read up about 2D Graphics?

db
• 01-16-2013, 09:16 AM
Zie_Mordecai
Re: Creating a Mathematical Curve in Java
I have a book called JAVA 2D Graphics by Jonathan Knudsen. I can create the frames, however making the x and y axis is somewhat misleading. Here is what I did,

public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;

}

That's how far I got.
Can you help me out please.
• 01-16-2013, 10:08 AM
DarrylBurke
Re: Creating a Mathematical Curve in Java
• 01-16-2013, 10:11 AM
DarrylBurke
Re: Creating a Mathematical Curve in Java
Also, you didn't reply to my 3 simple questions and it's clear that you haven't gone through the painting tutorial. If you're not going to take advice, why ask for it?

db