COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### 3D to 2D projection

• Email
• Follow

```I am trying to map a hemisphere to a circle, i.e getting subplot
(1,2,2) from subplot(1,2,1) of the code below. Is there a set
transformation matrix that exist to do this mapping without needing to
specify view([0 90]) ?

My overall task is to fill each square or even trapezoid on the
'walls' of the hemisphere with an image and then project them to a 2D
circular image. I am not quite sure how to do that! Any advice on the
data structures and transformations to use will be greatly
appreciated.

----------------------
n = 18; % n is the number of points in the drawing of the sphere.

theta = 2*pi*(0:n)/n; %polar angle
phi = (pi/2)*(0:3:n)'/n; % azimuthal angle
r = R*cos(phi);

% Parametric Equation of a sphere X(r,theta,phi),Y(r,theta,phi),Z
(r,theta,phi):
xsphere = r*cos(theta);
ysphere = r*sin(theta);
zsphere = R*sin(phi)*ones(size(theta));

%Plots
subplot(1,2,1)
surf(xsphere,ysphere,zsphere);
axis equal

subplot(1,2,2)
surf(xsphere,ysphere,zsphere);
view([0 90]);
grid('off')
```
 0
Reply viv3kg (13) 12/14/2009 11:24:46 AM

See related articles to this posting

```On 14 Des, 12:24, "Jean V.G" <viv...@gmail.com> wrote:
> I am trying to map a hemisphere to a circle, i.e getting subplot
> (1,2,2) from subplot(1,2,1) of the code below. Is there a set
> transformation matrix that exist to do this mapping without needing to
> specify view([0 90]) ?

The 'simplest' way that did not manipulate VIEW would
be to disregard the z coordinate, and use PATCH to
plot the individual faces in the (x,y) plane. This
*can* be done without using VIEW, but it is far simpler
for you to just set the z coordinate to 0 and use VIEW.

Rune
```
 0

1 Replies
998 Views

Similar Articles

12/6/2013 9:30:49 AM
page loaded in 4666 ms. (0)