-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreplot_field_obj.m
59 lines (47 loc) · 1.81 KB
/
replot_field_obj.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function replot_field_obj(field_obj)
%REPLOT_FIELD_OBJ Update position of field object field_obj in plot.
switch field_obj.type
case "charge"
x = field_obj.position(1);
y = field_obj.position(2);
z = field_obj.position(3);
field_obj.plotobj.XData = x;
field_obj.plotobj.YData = y;
field_obj.plotobj.ZData = z;
% Update shadows if they exist
if isfield(field_obj, 'xshadow_plotobj')
field_obj.xshadow_plotobj.YData = y;
field_obj.xshadow_plotobj.ZData = z;
field_obj.yshadow_plotobj.XData = x;
field_obj.yshadow_plotobj.ZData = z;
field_obj.zshadow_plotobj.XData = x;
field_obj.zshadow_plotobj.YData = y;
end
case {"eDipole", "mDipole"}
x = field_obj.position(1);
y = field_obj.position(2);
z = field_obj.position(3);
field_obj.plotobj.XData = x-0.05;
field_obj.plotobj.YData = y;
field_obj.plotobj.ZData = z;
% Update shadows if they exist
if isfield(field_obj, 'xshadow_plotobj')
field_obj.xshadow_plotobj.YData = y;
field_obj.xshadow_plotobj.ZData = z;
field_obj.yshadow_plotobj.XData = x;
field_obj.yshadow_plotobj.ZData = z;
field_obj.zshadow_plotobj.XData = x;
field_obj.zshadow_plotobj.YData = y;
end
case "current"
x = field_obj.position(1);
y = field_obj.position(2);
field_obj.plotobj.XData = [x,x];
field_obj.plotobj.YData = [y,y];
% Update shadows if they exist
if isfield(field_obj, 'xshadow_plotobj')
field_obj.xshadow_plotobj.YData = [y,y];
field_obj.yshadow_plotobj.XData = [x,x];
end
end
end