This week's giveaway is in the Android forum. We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line! See this thread for details.

I have to write a program which can draw contour plot(level curves) of every function, but i do not know how to calculate x and y in f(x,y)=z to draw the level curves?
I could not find any source code which can help me

Thanks in advance

parasto harir
Greenhorn

Joined: Jan 04, 2013
Posts: 8

posted

0

Thanks for your reply but the video was not related to level curves, I did not get the idea.

parasto harir
Greenhorn

Joined: Jan 04, 2013
Posts: 8

posted

0

I could not find my subject in that site too, you mean that I send them email?

Actually, I think you followed a link to a sponsor, not actually a reply to your question.

Can you explain how you'd draw these level curves without a program? If you can, we can probably help you translate the process into Java code.

parasto harir
Greenhorn

Joined: Jan 04, 2013
Posts: 8

posted

0

Thank you for your reply,
Actually my program receives step size, first level and number of contours from user then it has to calculate the collection of all points (x,y) in the domain of a function f for which f(x,y) = c .
then it will show all level curves in related area
I want to have some result similar to this site:

but I do not know how to find the exact value of x and y when f(x,y)= c ?

parasto harir
Greenhorn

Joined: Jan 04, 2013
Posts: 8

posted

0

Thank you for your reply,
Actually my program receives step size, first level and number of contours from user then it has to calculate the collection of all points (x,y) in the domain of a function f for which f(x,y) = c .
then it will show all level curves in related area
I want to have some result similar to this site:

Well, that's a cool link. It doesn't seem to be calculating x and y for a given z though, like you would need to draw a topography map of a mountain. Instead it's drawing a three dimensional graph showing z values for all x, y over some range. It draws some lines on the graph for fixed values of x and y, but not fixed values of z.

Let's say that you actually do need to calculate f(x,y) = c though. You would need to solve for y in terms of x, and then plot that on a two-dimension graph. For example, you have the formula for a cone: z=√ (x² +y²) , and you want to solve that for z = 4. You rearrange it as y = √(16 -x²), which gives you a circle with radius 4. Again, that's math though, not Java programing. You should have a firm grasp of the math before you even think about converting it to a program.

parasto harir
Greenhorn

Joined: Jan 04, 2013
Posts: 8

posted

0

Thanks for your reply =) and one more question

I have two frame and I defined two different canvas for each of them, one of them which I defined another class for that does not work with my code:

public void paint(Graphics g) {
g.drawOval(13, 23, 65, 66);
}

I do not what is wrong , because I need to draw my object by using those code, I call this class by " contour_canvas.paint(drawable); " in the main class?

parasto harir
Greenhorn

Joined: Jan 04, 2013
Posts: 8

posted

0

Hi,

yes it seems to be easy to calculate for y in terms of x, in f(x,y)=c . but I have to find a solution which is good enough for general types of equation. in your example it was easy to calculate y and x but for example in :
x² +y²+3+log(x)-cos(x+y) = c how should I solve that?