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

19
Rendering Implicit Plots

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

Page 1: 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.

Rendering Implicit Plots

Page 2: 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.

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.

Page 3: 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.

Rendering an Implicit PlotStandard Approach

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

Page 4: 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.

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

Page 5: 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.

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

Page 6: 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.

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

Page 7: 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.

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.

Page 8: 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.

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.

Page 9: 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.

Adjustable Mesh

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

Page 10: 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.

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.

Page 11: 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.

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.

Page 12: 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.

Adjustable Mesh

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

Page 13: 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.

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.

Page 14: 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.

Adjustable Mesh

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

Page 15: 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.

Existing Implementations

This type of algorithm has been implemented in both:

Mathematica Maple

Page 16: 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.

Our Implementations

We developed two implementations of the adjustable mesh algorithm.

One in Java and the other in Sage.

Page 17: 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.

Adjustable Mesh - Actual Performance

Page 18: 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.

cos(x+y) - (xy)2

Page 19: 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.

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