Skip to content

Instantly share code, notes, and snippets.

@philippslang
Last active January 4, 2016 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippslang/ffc64caaccbec7031c3b to your computer and use it in GitHub Desktop.
Save philippslang/ffc64caaccbec7031c3b to your computer and use it in GitHub Desktop.
Matlab Tensor Visualization
function [hmame, hmami] = Ellipsoid_discs_plot(vma, vme, vmi)
%Ellipsoid_discs_plot plots an ellipsoid as two
%elliptical discs.
%
%The center of the ellipsoid is assumed to be 0,0,0. The tool has been
%designed to visualize tensorial properties using the characteristic
%Eigenvectors. Using cross-section elliptical discs to visualize ellipsoids
%may provide improved visualization compared to volumetric ellipsoids.
%
% Parameters
% vma - Eigenvector correspoding to maximum Eigenvalue
% vme - Eigenvector correspoding to intermediate Eigenvalue
% vme - Eigenvector correspoding to minimum Eigenvalue
%
% Returns
% [hmame, hmami] - Graphics handles to discs for max-med and max-min,
% respectively (Matlab's fill3)
vmajor = vma;
vminors = {vme,vmi};
hs = cell(2);
for i = 1:2
vminor = vminors{i};
% theta for parametric representation of ellipse
theta = linspace(0,2*pi,50);
% points on ellipse from parametric form
X = cos(theta)*vmajor(1) + sin(theta)*vminor(1);
Y = cos(theta)*vmajor(2) + sin(theta)*vminor(2);
Z = cos(theta)*vmajor(3) + sin(theta)*vminor(3);
% 3D filled polygon, color and alpha can be changed using handles
gr = 0.6;
hms = fill3(X,Y,Z,[gr,gr,gr]);
set(hms, 'FaceAlpha', 0.7);
hold on;
hs{i} = hms;
end
hmame = hs{1};
hmami = hs{2};
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment