Rendering Implicit Plots. What is an Implicit Plot? An implicit plot is a plot of all the points...

Post on 20-Jan-2016

224 views 0 download

Transcript of Rendering Implicit Plots. What is an Implicit Plot? An implicit plot is a plot of all the points...

Rendering Implicit Plots

What is an Implicit Plot?

An implicit plot is a plot of all the points satisfying equation:

f(x,y) = 0 (for some function f) The points plotted are connected by lines to

form one or more curves.

Rendering an Implicit PlotStandard Approach

Start with a grid of evenly spaced points and evaluate the function at each point on the grid.

Rendering an Implicit Plot Standard Approach

Look at each square in the grid. If f has a different sign for two adjacent

corners then somewhere in between it was 0. Linear Approximation can be used

to estimate the point on the line where f(x,y) = 0

Linear Approximation

Start with the two points (x0,y

0), (x

1,y

1) where the sign change in f

occurred

We know that somewhere on the line between (x0,y

0), (x

1,y

1) that the

value of f is 0

The parametric equation of a line is defined as follows:

(x,y) = (x0,y

0)(1-t)+(x

1,y

1)t

What we do is use this equation to approximate f for values of x and y

f(x,y) = f(x0,y

0)(1-t)+f(x

1,y

1)t

Here we are only interested in finding where f(x,y) = 0

0 = f(x0,y

0)(1-t)+f(x

1,y

1)t

Linear Approximation - Continued

We are now able to solve 0 = f(x0,y

0)(1-t)+f(x

1,y

1)t for t and plug the result

back into (x,y) = (x0,y

0)(1-t)+(x

1,y

1)t

This results in the following point:

x , y = x0 f x1 , y1 x 1 f x 0 , y0 f x1 , y1− f x 0 , y0

, y0 f x1 , y1 y1 f x 0 , y0

f x1 , y1− f x0 , y0

Problem with the standard approach

If the grid isn't fine enough part of the curve might be missed.

A simple but inefficient solution would be to just make the grid more finely grained.

Rendering Plots using an Adjustable Mesh

The idea behind an adjustable mesh is to start with a reasonable grid and only increase the grid's resolution in areas where it's necessary.

Adjustable Mesh

Starting with an initial grid the algorithm looks for areas where the function changes rapidly and increases the resolution in those areas.

Adjustable Mesh - Data Structure

The data structure for the adjustable mesh is made up of two main components.

Edges 2 points that define the line segment References to the two faces holding the edge

Faces Composed of 3 edges:

Two edges sharing a common vertex A hypotenuse that shares a vertex with each of

the edges.

Determining how much the function changes

Given three points and the value of the function at each point we can create 2 3D vectors and look at the angle between the vectors.

Adjustable Mesh

To avoid tears in the plot sides shared by two regions must be the same.

Adjustable Mesh

By adding a point in the middle of a square and dividing the square into 4 triangles. It is possible to increase the resolution without affecting adjacent squares.

Adjustable Mesh

The grid can be further subdivided by adding the midpoint of the newly created square.

Existing Implementations

This type of algorithm has been implemented in both:

Mathematica Maple

Our Implementations

We developed two implementations of the adjustable mesh algorithm.

One in Java and the other in Sage.

Adjustable Mesh - Actual Performance

cos(x+y) - (xy)2

Comparing Performance

cos(x+y) - (xy)2

X-Range: (-3,3) Y-Range: (-3,3) Adjustable Mesh: 5.23 seconds Standard Algorithm: 2.08 seconds

X-Range: (-10,10) Y-Range: (-10,10) Adjustable Mesh: 8.78 seconds Standard Algorithm: 21.48 seconds