tomd
tomd

Reputation: 239

Algorithm for smooth plotting (Java2d)

I am trying to plot a curve of y = f(x) for various functions, and I want the plot to be as good quality as possible. That said, I would prefer to avoid rendering individual pixels in my Java code for performance reasons.

In other words, I want to squeeze as much quality as I can out of Java2D.

Currently I am calculating float (x,y) values for each pixel in the x direction. Then I am creating a Shape by drawing lines between these points (using float values for the point coords). I have render hints for bilinear interpolation, anti-aliasing and quality rendering.

The result isn't terrible, it is just about passable, but I have seen better. I think the problem is, even though I am using float coordinates I am essentially drawing a polygon so there is only so much Java2D can do.

Is there anything more I can do to improve this?

Upvotes: 0

Views: 710

Answers (1)

JiP
JiP

Reputation: 3258

When I was studying computer graphics at university, we did a coursework based on "Bézier Curve". It may be an algorithm you are looking for. Look here for more detail:

http://en.wikipedia.org/wiki/Bézier_curve

Basically it is a way how to replace a polygon with a smooth curve.

Upvotes: 1

Related Questions