Skip to content

Commit 6614067

Browse files
Preparation for Zenodo commit
1 parent 84bb3ad commit 6614067

File tree

7 files changed

+49
-41
lines changed

7 files changed

+49
-41
lines changed

+anakin/basis.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ purely numeric matrix (symbolic variables must be used)
109109
end
110110
end
111111
end
112-
methods % overloads
112+
methods (Hidden = true) % overloads
113113
function value = eq(B1,B2) % overload ==
114114
if isa(B1.m,'sym') || isa(B1.m,'sym') % symbolic inputs
115115
value = isAlways(B1.m==B2.m,'Unknown','false'); % In case of doubt, false

+anakin/particle.m

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
22
DESCRIPTION:
3-
particle: class to model a point particle. Inherits from point.
3+
particle: class to model a point particle.
44
55
SYNTAX:
66
P0 = anakin.particle(); % returns default object
@@ -33,10 +33,13 @@
3333
AUTHOR:
3434
Mario Merino <[email protected]>
3535
%}
36-
classdef particle < anakin.point
36+
classdef particle
3737
properties
3838
mass anakin.tensor = anakin.tensor(1); % mass of the object
39-
forces cell = {}; % cell array with all forces acting on the particle
39+
point anakin.point = anakin.point; % point where the object is
40+
end
41+
properties % extensions
42+
forces cell = {}; % cell array with all forces (vectors) acting on the object
4043
end
4144
methods % creation
4245
function P = particle(varargin) % constructor
@@ -45,23 +48,23 @@
4548
return;
4649
case 1
4750
Pt = anakin.particle(varargin{1},anakin.frame);
48-
P.pos0 = Pt.pos0;
4951
P.mass = Pt.mass;
52+
P.point = Pt.point;
5053
case 2
5154
if isa(varargin{end},'anakin.frame') % last is frame
5255
if isa(varargin{1},'anakin.point') || isa(varargin{1},'anakin.tensor') || numel(varargin{1}) == 3 % (vector or components), frame
53-
P.pos0 = anakin.tensor(varargin{2}.basis.matrix * anakin.tensor(varargin{1}).components + varargin{2}.origin.coordinates);
54-
else % mass, frame
55-
P.pos0 = varargin{2}.origin;
56+
P.point = anakin.point(varargin{2}.basis.matrix * anakin.tensor(varargin{1}).components + varargin{2}.origin.coordinates);
57+
else % mass, frame
5658
P.mass = anakin.tensor(varargin{1});
59+
P.point = varargin{2}.origin;
5760
end
5861
else
5962
Pt = anakin.particle(varargin{1},varargin{2},anakin.frame);
60-
P.pos0 = Pt.pos0;
6163
P.mass = Pt.mass;
64+
P.point = Pt.point;
6265
end
6366
case 3
64-
P.pos0 = anakin.tensor(varargin{3}.basis.matrix * anakin.tensor(varargin{2}).components + varargin{3}.origin.coordinates);
67+
P.point = anakin.point(varargin{3}.basis.matrix * anakin.tensor(varargin{2}).components + varargin{3}.origin.coordinates);
6568
P.mass = anakin.tensor(varargin{1});
6669
otherwise % other possibilities are not allowed
6770
error('Wrong number of arguments in particle');
@@ -88,42 +91,48 @@
8891
P.forces = value;
8992
end
9093
end
91-
methods(Hidden = true) % overloads
94+
methods (Hidden = true) % overloads
95+
function value = eq(P1,P2) % overload ==
96+
value = (P1.point == P2.point) && (P1.mass == P2.mass);
97+
end
98+
function value = ne(P1,P2) % overload =~
99+
value = ~eq(P1,P2);
100+
end
92101
function disp(P) % display
93102
disp('Particle with mass:')
94103
disp(P.mass.components)
95-
disp('And canonical position vector components:')
96-
disp(P.pos.components)
104+
disp('And canonical coordinates:')
105+
disp(P.point.coordinates)
97106
end
98107
end
99-
methods % functionality
108+
methods % general functionality
100109
function p = p(P,S1) % linear momentum in S1
101110
if exist('S1','var')
102-
p = P.mass*P.vel(S1);
111+
p = P.mass*P.point.vel(S1);
103112
else
104-
p = P.mass*P.vel;
113+
p = P.mass*P.point.vel;
105114
end
106115
end
107116
function H = H(P,O,S1) % angular momentum about O in S1
108117
if ~exist('O','var')
109118
O = anakin.point; % default point
110119
end
111120
if exist('S1','var')
112-
H = cross(P.pos0-O.pos0, P.p(S1));
121+
H = cross(P.point.pos0-O.pos0, P.p(S1));
113122
else
114-
H = cross(P.pos0-O.pos0, P.p);
123+
H = cross(P.point.pos0-O.pos0, P.p);
115124
end
116125
end
117126
function T = T(P,S1) % kinetic energy in S1
118127
if exist('S1','var')
119-
vel = P.vel(S1).components;
128+
vel = P.point.vel(S1).components;
120129
else
121-
vel = P.vel.components;
130+
vel = P.point.vel.components;
122131
end
123132
T = (P.mass/2) * dot(vel,vel);
124133
end
125134
function eqs = equations(P,B1) % returns vector of equations of motion projected in basis B1
126-
MA = P.mass*P.accel;
135+
MA = P.mass*P.point.accel;
127136
F = anakin.tensor([0;0;0]); % allocate;
128137
for i=1:length(P.forces)
129138
F = F + P.forces{i};
@@ -142,15 +151,15 @@ function disp(P) % display
142151
end
143152
function inertia = inertia(P,O) % inertia tensor of the particle with respect to point O
144153
if exist('O','var')
145-
r = P.pos0 - O;
154+
r = P.point.coordinates - O.coordiantes;
146155
else
147-
r = P.pos0;
156+
r = P.point.coordinates;
148157
end
149158
inertia = P.mass * (norm(r)^2 * anakin.tensor(eye(3)) - product(r,r));
150159
end
151160
function P_ = subs(P,variables,values) % particularize symbolic vector
152161
P_ = P;
153-
P_.pos0 = P.pos0.subs(variables,values);
162+
P_.point = P.point.subs(variables,values);
154163
P_.mass = P.mass.subs(variables,values);
155164
end
156165
end

+anakin/point.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ of the point with respect to another reference frame (symbolic variables
4343
end
4444
end
4545
end
46-
methods % overloads
46+
methods (Hidden = true) % overloads
4747
function value = eq(A1,A2) % overload ==
4848
value = (A1.pos0 == A2.pos0);
4949
end
50-
function value = ne(A1,A2)
50+
function value = ne(A1,A2) % overload =~
5151
value = ~eq(A1,A2);
5252
end
5353
function disp(A) % display
@@ -78,29 +78,29 @@ function disp(A) % display
7878
A_ = A;
7979
A_.pos0 = A.pos0 + a;
8080
end
81-
function rO_1 = pos(A,S1) % Returns the position vector of the point with respect to reference frame S1
81+
function r = pos(A,S1) % Returns the position vector of the point with respect to reference frame S1
8282
if exist('S1','var') % If no S1 is given, assume the canonical reference frame
83-
rO_1 = A.pos0 - S1.origin;
83+
r = A.pos0 - S1.origin;
8484
else
85-
rO_1 = A.pos0;
85+
r = A.pos0;
8686
end
8787
end
88-
function vO_1 = vel(A,S1) % Returns the velocity vector of the point with respect to reference frame S1
88+
function v = vel(A,S1) % Returns the velocity vector of the point with respect to reference frame S1
8989
if exist('S1','var') % If no S1 is given, assume the canonical reference frame
90-
rO_1 = A.pos(S1);
91-
vO_1 = rO_1.dt(S1.basis);
90+
r = A.pos(S1);
91+
v = r.dt(S1.basis);
9292
else
93-
rO_1 = A.pos;
94-
vO_1 = rO_1.dt;
93+
r = A.pos;
94+
v = r.dt;
9595
end
9696
end
97-
function aO_1 = accel(A,S1) % Returns the acceleration vector of the point with respect to reference frame S1
97+
function a = accel(A,S1) % Returns the acceleration vector of the point with respect to reference frame S1
9898
if exist('S1','var') % If no S1 is given, assume the canonical reference frame
99-
vO_1 = A.vel(S1);
100-
aO_1 = vO_1.dt(S1.basis);
99+
v = A.vel(S1);
100+
a = v.dt(S1.basis);
101101
else
102-
vO_1 = A.vel;
103-
aO_1 = vO_1.dt;
102+
v = A.vel;
103+
a = v.dt;
104104
end
105105
end
106106
function A_ = subs(A,variables,values) % Particularize symbolic frame

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ Currently Anakin defines the following classes:
4444
* `basis`: vector bases
4545
* `frame`: reference frames
4646
* `point`: geometric points
47-
* `particle`: point particles
48-
* `body`: rigid bodies
47+
* `particle`: point particles
4948

5049
The description of the properties and methods of each class is included in the
5150
header comments of each code file.
File renamed without changes.

problems/figs/solved_motion.avi

-4.75 MB
Binary file not shown.
-29.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)