The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 create a surface of a sphere
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

belsebub01

1 Posts

Posted - 04/20/2010 :  2:58:12 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 8 SR4
Operating System: Win 7

I have a project to create a surface of a sphere with gridlines. For this I need to create a matrix, hope I'm right.

I want to use the function for a shere: x+y+z=r , but I don't find a solution to convert this function into a matrix. Can anybody help???

Thanks a lot!

Sam Fang

291 Posts

Posted - 04/21/2010 :  11:07:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Sam Fang on 04/22/2010 04:58:16 AM
Go to Top of Page

greg

USA
1378 Posts

Posted - 04/22/2010 :  1:56:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Before everyone wears a hole in their head from all that scratching, I'd like to point out two things:

In 8.0 we did not support hiding of missing values, so your version will display a plane at z = 0.

As of Origin 8.1, we do not yet fully support multiple matrices in a surface plot. If you create the graph, you will find that display order or certain rotation angles will not result in a correct display.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000