Introduction

This article describes very briefly (and on a basic level) how to plot user interactive 3D R2 in R surfaces using C# ASP.NET. The example enables the user to interact with the drawing in 5 aspects as below:

function expression z = f(x,y)

domain

integration step

rotation about x, y and z axis

model (wireframe or fill)

Background

A point in R3 is a set of 3 float values (x,y,z) which defines a position.

R2 in R functions are expresions in the form z = f(x,y) where x and y are a subset of the function domain.

The R2 in R domain is the R2 or better, the xy plane.

The cartesian coordinates

The objective is to get a set of z coordinates applying a generic function z=f(x,y) to a discrete domain, or better a matrix of defined x and y points as the image grid above.

How to Perform This

At first we need to define the domain. Let's choose [-1.7,1.3] for x and [-2.1,2.5] for y what means x will run from -1.7 to 1.3 and y will run from -2.1 to 2.5.

How to Run the Points

As we are working with R coordinates we have infinite points between 2 coordinates, so for this we need a step variable, which means the integration we will use to get the grid points.

Now with above definitions we can handle a generation of z coordinates from running the xy discrete subdomain by using the generic function z = f(x,y)

double x0=-1.7, x1=1.3, y0=-2.1, y1=2.5;
double step = 0.1;
double x=x0;
double z;
while(x<=x1)
{
//...
y=y0;
while(y<=y1)
{
//...
y+=step;
z = function(x,y); // at this point we have x,y and z coordinates// all we need now is to keep this information in a data structure// to plot the whole data in a next step
}
x+=step;
}

Now the Tricky Part

We could use a MathExpressionParser with the expression string, but here I made it more simple with the help of a template with a tag. The process is easy: read the template file, replace the tag, and write the ASPX file which shows the image.