Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added 'valid' output and updated comments.

  • Loading branch information...
commit 628b06bc95adf52df405bd33bf4060b072687490 1 parent 0580301
Jean-Francois Lalonde authored
Showing with 34 additions and 33 deletions.
  1. +12 −11 envmapAngular2World.m
  2. +10 −11 envmapCube2World.m
  3. +12 −11 envmapLatLong2World.m
View
23 envmapAngular2World.m
@@ -1,6 +1,7 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% function [dx,dy,dz] = envmapAngular2World(dim)
-% Converts an environment map from the angular format to the [x,y,z] world directions
+function [dx,dy,dz,valid] = envmapAngular2World(dim)
+% Converts from the angular format to the [x,y,z] world directions
+%
+% [dx,dy,dz] = envmapAngular2World(dim)
%
% Input parameters:
% - dim: the angular environment dimensions
@@ -8,13 +9,8 @@
% Output parameters:
% - [dx,dy,dz]: world directions
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [dx,dy,dz] = envmapAngular2World(dim)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Copyright 2006-2009 Jean-Francois Lalonde
-% Carnegie Mellon University
-% Do not distribute
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% ----------
+% Jean-Francois Lalonde
%% Get the desired world coordinates from the output angular map
[u,v] = meshgrid(0:1/(dim-1):1, 0:1/(dim-1):1);
@@ -24,4 +20,9 @@
dx = sin(phiAngular).*cos(thetaAngular);
dy = sin(phiAngular).*sin(thetaAngular);
-dz = -cos(phiAngular);
+dz = -cos(phiAngular);
+
+if nargout > 3
+ r = (u-0.5).^2 + (v-0.5).^2;
+ valid = r <= .25; % .5^2
+end
View
21 envmapCube2World.m
@@ -1,6 +1,7 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% function [dx,dy,dz] = envmapCube2World(dim)
-% Converts an environment map from the cube format to the [x,y,z] world directions
+function [dx,dy,dz,valid] = envmapCube2World(dim)
+% Converts from the cube format to the [x,y,z] world directions
+%
+% [dx,dy,dz] = envmapCube2World(dim)
%
% Input parameters:
% - dim: the cube environment dimensions
@@ -8,13 +9,9 @@
% Output parameters:
% - [dx,dy,dz]: world directions
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [dx,dy,dz] = envmapCube2World(dim)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Copyright 2006-2009 Jean-Francois Lalonde
-% Carnegie Mellon University
-% Do not distribute
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% ----------
+% Jean-Francois Lalonde
+
[u,v] = meshgrid(0:3/(3.*dim-1):3, 0:4/(4.*dim-1):4);
dx = zeros(size(u)); dy = zeros(size(u)); dz = zeros(size(u));
@@ -61,7 +58,9 @@
dy = dy ./ norm;
dz = dz ./ norm;
-
+if nargout > 3
+ valid = ~isnan(dx);
+end
View
23 envmapLatLong2World.m
@@ -1,6 +1,7 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% function [dx,dy,dz] = envmapLatLong2World(height)
-% Converts an environment map from the angular format to the [x,y,z] world directions
+function [dx,dy,dz,valid] = envmapLatLong2World(height)
+% Converts from the angular format to the [x,y,z] world directions
+%
+% [dx,dy,dz,valid] = envmapLatLong2World(height)
%
% Input parameters:
% - height: height of the latitude-longitude output (width = 2*height)
@@ -8,13 +9,8 @@
% Output parameters:
% - [dx,dy,dz]: world directions
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [dx,dy,dz] = envmapLatLong2World(height)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Copyright 2006-2009 Jean-Francois Lalonde
-% Carnegie Mellon University
-% Do not distribute
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% ----------
+% Jean-Francois Lalonde
%% Get the desired world coordinates from the output lat-long map
[u,v] = meshgrid(0:2/(2.*height-1):2, 0:1/(height-1):1);
@@ -24,4 +20,9 @@
dx = sin(phiLatLong).*sin(thetaLatLong);
dy = cos(phiLatLong);
-dz = -sin(phiLatLong).*cos(thetaLatLong);
+dz = -sin(phiLatLong).*cos(thetaLatLong);
+
+% all the coordinates are valid
+if nargout > 3
+ valid = true(size(dx));
+end
Please sign in to comment.
Something went wrong with that request. Please try again.