Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Cubed Sphere

Subject: Cubed Sphere

From: Matt

Date: 13 Aug, 2009 19:13:02

Message: 1 of 12

Hi All --

Does anyone have an algorithm to generate a cubed sphere? Ideally, I would pass the function a scalar (e.g., # of tiles per face) and would receive the Cartesian coordinates of every vertex on the cubed sphere. Thanks a bunch.

Matt

Subject: Cubed Sphere

From: Roger Stafford

Date: 13 Aug, 2009 20:08:01

Message: 2 of 12

"Matt" <matt_evans.nospam@ncsu.edu> wrote in message <h61oju$d55$1@fred.mathworks.com>...
> Hi All --
>
> Does anyone have an algorithm to generate a cubed sphere? Ideally, I would pass the function a scalar (e.g., # of tiles per face) and would receive the Cartesian coordinates of every vertex on the cubed sphere. Thanks a bunch.
>
> Matt

  Little is to be gained by presenting a task that has been the subject of many papers. It is not an appropriate problem for this kind of newsgroup.

Roger Stafford

Subject: Cubed Sphere

From: Matt

Date: 13 Aug, 2009 20:15:17

Message: 3 of 12

> Little is to be gained by presenting a task that has been the subject of many papers. It is not an appropriate problem for this kind of newsgroup.
>
> Roger Stafford

Roger -- thanks for your reply. I have seen many papers that discuss the USE of the cubed sphere, but none that address the generation of said sphere. Perhaps this problem is trivial for topologists or computer scientists, but I am neither. Could you be so kind as to point me in the direction of some of these references.

Matt

Subject: Cubed Sphere

From: Roger Stafford

Date: 13 Aug, 2009 20:48:02

Message: 4 of 12

"Matt" <matt_evans.nospam@ncsu.edu> wrote in message <h61s8l$ph0$1@fred.mathworks.com>...
> Roger -- thanks for your reply. I have seen many papers that discuss the USE of the cubed sphere, but none that address the generation of said sphere. Perhaps this problem is trivial for topologists or computer scientists, but I am neither. Could you be so kind as to point me in the direction of some of these references.
>
> Matt

  Perhaps I didn't make myself clear, Matt. What I meant was that this problem undoubtedly involves a very extensive programming effort even if good algorithms have been devised. In other words, it is the opposite of being too trivial; it is not trivial enough. It is for this reason that I deem it inappropriate here in this newsgroup. We prefer answering questions that can be explained in just a few lines of code, and I seriously doubt that that would be true for generating cubed spheres, particularly of the generality of an arbitrary number of tiles per face that you are looking for.

  You might check on the Matlab File Exchange to see if anyone has taken the trouble to deal with it. I do see a www site that seems to be concerned with this area and involves matlab routines:

 http://mitgcm.org/r2_web_testing/latest/online_documents/node227.html

Roger Stafford

Subject: Cubed Sphere

From: Bruno Luong

Date: 13 Aug, 2009 21:45:20

Message: 5 of 12

"Matt" <matt_evans.nospam@ncsu.edu> wrote in message <h61oju$d55$1@fred.mathworks.com>...
> Hi All --
>
> Does anyone have an algorithm to generate a cubed sphere? Ideally, I would pass the function a scalar (e.g., # of tiles per face) and would receive the Cartesian coordinates of every vertex on the cubed sphere. Thanks a bunch.
>
> Matt

Try this:

n=10; % making (9 x 9 tiles per faces) for one of the six faces

x = 1;
y = linspace(-1,1,n);
z = y;
[X Y Z] = ndgrid(x,y,z);

S = sqrt(1./(X.^2+Y.^2+Z.^2));
X = X.*S;
Y = Y.*S;
Z = Z.*S;

C1 = [X(:) Y(:) Z(:)].';
M = makehgtform('zrotate',pi/2);
C2 = M(1:3,1:3)*C1;
M = makehgtform('zrotate',pi);
C3 = M(1:3,1:3)*C1;
M = makehgtform('zrotate',3*pi/2);
C4 = M(1:3,1:3)*C1;
M = makehgtform('yrotate',pi/2);
C5 = M(1:3,1:3)*C1;
M = makehgtform('yrotate',-pi/2);
C6 = M(1:3,1:3)*C1;

C = [C1 C2 C3 C4 C5 C6].';
tol = 1e-3/(n-1);
Cround = round(C/tol);
[Cround I] = unique(Cround,'rows');
Vertex = C(I,:);

figure(1); clf
plot3(Vertex(:,1),Vertex(:,2),Vertex(:,3),'.');
axis equal

% Bruno

Subject: Cubed Sphere

From: Matt

Date: 13 Aug, 2009 22:22:02

Message: 6 of 12

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h621hg$sfs$1@fred.mathworks.com>...
> Try this:
>
Bruno --

Thanks a bunch for the reply.

I think that works -- but it is difficult for me to be certain until I figure out a better way to visualize it. The point cloud "looks right", but I want to see the actual grid to confirm this.

Thanks again.

Matt

Subject: Cubed Sphere

From: Bruno Luong

Date: 13 Aug, 2009 22:56:03

Message: 7 of 12

% Now you can chek it:

n=17;

x = 1;
y = linspace(-1,1,n);
z = y;
[X Y Z] = ndgrid(x,y,z);

S = sqrt(1./(X.^2+Y.^2+Z.^2));
X = X.*S;
Y = Y.*S;
Z = Z.*S;

C1 = [X(:) Y(:) Z(:)].';
M = makehgtform('zrotate',pi/2);
C2 = M(1:3,1:3)*C1;
M = makehgtform('zrotate',pi);
C3 = M(1:3,1:3)*C1;
M = makehgtform('zrotate',3*pi/2);
C4 = M(1:3,1:3)*C1;
M = makehgtform('yrotate',pi/2);
C5 = M(1:3,1:3)*C1;
M = makehgtform('yrotate',-pi/2);
C6 = M(1:3,1:3)*C1;

[i j] = ndgrid(1:n-1,1:n-1);
i = i(:); j=j(:);
P = [sub2ind([n n], i, j) ...
     sub2ind([n n], i+1, j) ...
     sub2ind([n n], i+1, j+1) ...
     sub2ind([n n], i, j+1)];
offset = n^2*(0:5)';
P = bsxfun(@plus, offset, reshape(P,[1 size(P)]));
P = reshape(P, [], 4);

C = [C1 C2 C3 C4 C5 C6].';
tol = 1e-3/(n-1);
Cround = round(C/tol);
[Cround I J] = unique(Cround,'rows');
Vertices = C(I,:);
P = J(P);

figure(1); clf;
patch('Vertices',Vertices,'Faces',P,'FaceColor','g');
axis equal

% Bruno

Subject: Cubed Sphere

From: Matt

Date: 14 Aug, 2009 02:47:02

Message: 8 of 12

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h625m3$7tk$1@fred.mathworks.com>...
> % Now you can chek it:
>

Bruno -- quite nice, indeed. This is perfect. Thanks very much for the help.

Matt

Subject: Cubed Sphere

From: Bruno Luong

Date: 14 Aug, 2009 12:09:20

Message: 9 of 12

FYI I have updated the code with another grid parametrization (equiangular). It seems more popularly used. It has been submitted to FEX.

While googling, I see a lot of papers around conformal mapping, which has the advantages as well as the inconveniences. I couldn't implement because of lack of a detailed description (selection of the pole, etc...). I can't have access to relevant paper.

Bruno

Subject: Cubed Sphere

From: Matt

Date: 14 Aug, 2009 14:50:20

Message: 10 of 12

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h63k5g$oo0$1@fred.mathworks.com>...
> FYI I have updated the code with another grid parametrization (equiangular). It seems more popularly used. It has been submitted to FEX.
>
> While googling, I see a lot of papers around conformal mapping, which has the advantages as well as the inconveniences. I couldn't implement because of lack of a detailed description (selection of the pole, etc...). I can't have access to relevant paper.
>
> Bruno

Bruno -- thanks a ton. I'd like to try the updated code, but I do not see it yet on the File Exchange. How long does it typically take for files to become available? Thanks.

Matt

Subject: Cubed Sphere

From: Bruno Luong

Date: 14 Aug, 2009 15:11:07

Message: 11 of 12

Matt, normally it'll show up shortly. If in few hours nothing showed up I'll send you the code.

Bruno

Subject: Cubed Sphere

From: Bruno Luong

Date: 14 Aug, 2009 15:41:06

Message: 12 of 12

I'ts up! Enjoy.

Bruno

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us