Assume that R=10. Create two matrix objects in the MSheet, select Matrix: Set Dimensions from Origin menu. Set X from -10 to 10. Y from -10 to 10. Type the following script in the command window.
range mz = [MBook1]MSheet1!1;
range mz2 = [MBook1]MSheet1!2;
dxx = (mz.x2 - mz.x1)/(mz.ncols - 1);
dyy = (mz.y2 - mz.y1)/(mz.nrows - 1);
for( ii = 1; ii <= mz.nrows; ii++)
for( jj = 1; jj <= mz.ncols; jj++)
{
xa = mz.x1 + dxx*( jj - 1);
ya = mz.y1 +dyy*( ii - 1);
if( xa^2 + ya^2 <= 10^2 )
{
mz[ii, jj] = sqrt(10^2 - xa^2 - ya^2);
mz2[ii, jj] = -sqrt(10^2 - xa^2 - ya^2);
}
//Refine the border of XY domain
else if( xa^2 + ya^2 <= ( 10 + sqrt(dxx^2 + dyy^2) )^2)
{
mz[ii, jj] = 0;
mz2[ii, jj] = 0;
}
else
{
mz[ii, jj] = 1/0;
mz2[ii, jj] = 1/0;
}
}
Two matrix objects correspond to the top and bottom sphere. Note that missing values will be set beyond the XY domain of the sphere.
The following graph is created using Origin with two matrix objects of 101 columns and 101 rows.
Sam
OriginLab Technical Services