-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scadMirror.m
34 lines (33 loc) · 994 Bytes
/
scadMirror.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function object = scadMirror(surface, object, varargin)
%scadMirror - Mirrors the child element on a plane through the origin. The
%argument to mirror() is the normal vector of a plane intersecting the
%origin through which to mirror the object.
%%%
% surface - mirror's surface (numerical vector 1 x 3 [x, y, z])
%
% object - scadStructure
position = [];
color = [];
while ~isempty(varargin)
switch lower(varargin{1})
case 'position'
position = varargin{2};
case 'color'
color = varargin{2};
otherwise
end
varargin(1:2) = [];
end
formatSpec = '[ %d, %d, %d ]';
surface = compose(formatSpec, surface);
mirror_result = ['mirror(' surface{1} '){' newline];
mirror_result = [mirror_result char(object.structure) newline];
mirror_result = [mirror_result '}' ];
object.structure = mirror_result;
if ~isempty(color)
object = scadColor(color, object);
end
if ~isempty(position)
object = scadTranslate(position, object);
end
end