Skip to content

Commit

Permalink
geom3d/drawPlane3d.m: add support for drawing multiple planes at once
Browse files Browse the repository at this point in the history
  • Loading branch information
dlegland committed Aug 2, 2021
1 parent 38005c0 commit d6bb200
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions matGeom/geom3d/drawPlane3d.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
function h = drawPlane3d(plane, varargin)
%DRAWPLANE3D Draw a plane clipped by the current axes.
% Draw a plane clipped by the current axes.
%
% drawPlane3d(PLANE) draws a plane of the format:
% [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2]
%
% drawPlane3d(...,'PropertyName',PropertyValue,...) sets the value of the
% specified patch property. Multiple property values can be set with
% a single statement. See function patch for details.
% drawPlane3d(..., 'PropertyName', PropertyValue,...)
% Sets the value of the specified patch property. Multiple property
% values can be set with a single statement. See the function "patch" for
% details.
%
% drawPlane3d(AX,...) plots into AX instead of GCA.
% drawPlane3d(AX,...)
% plots into AX instead of GCA.
%
% H = drawPlane3d(...) returns a handle H to the patch object.
% H = drawPlane3d(...)
% returns a handle H to the patch object.
%
% Example
%
Expand All @@ -25,11 +28,11 @@
% set(gcf, 'renderer', 'zbuffer');
%
% See also
% planes3d, createPlane, patch
% planes3d, createPlane, patch

% ------
% Author: David Legland
% e-mail: david.legland@inra.fr
% e-mail: david.legland@inrae.fr
% INRA - TPV URPOI - BIA IMASTE
% created the 17/02/2005.
%
Expand All @@ -39,6 +42,21 @@
% 2011-07-19 fix a bug for param by Xin KANG (Ben)
%

% add support for drawing multiple planes at once
if size(plane, 1) > 1
nPlanes = size(plane, 1);
hp = zeros(nPlanes, 1);
for iPlane = 1:nPlanes
hp(iPlane) = drawPlane3d(plane(iPlane, :), varargin{:});
end

if nargout > 0
h = hp;
end

return;
end

% Parse and check inputs
valFun = @(x) size(x,1)==1 && isPlane(x);
defOpts.FaceColor = 'm';
Expand Down

0 comments on commit d6bb200

Please sign in to comment.