-
Notifications
You must be signed in to change notification settings - Fork 0
/
MotorPoint.m
84 lines (76 loc) · 2.95 KB
/
MotorPoint.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Core Model, 2022
% Written by Maya Davis
% Concept by Maya Davis and Melissa A. Redford
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% METHOD LIST
% MotorPoint
% Distance
% FindPerceptualPoint
% MakeJuncture
%% CLASS DEFINITION
classdef MotorPoint
% A motor point consists of its coordinates and the values that we
% want to use for x, y, and z when plotting.
%% PROPERTIES
properties
Coordinates;
x;
y;
z;
end
%% METHODS
methods
% Creating an object
function obj = MotorPoint(coordinates, CoordinateOptions)
arguments
coordinates (:,:) {mustBeNumeric}
CoordinateOptions.xRowIndex {mustBeNumeric} = 1
CoordinateOptions.yRowIndex {mustBeNumeric} = 2
CoordinateOptions.zRowIndex {mustBeNumeric} = nan
CoordinateOptions.xCoordinates (1,:) = nan
CoordinateOptions.yCoordinates (1,:) = nan
CoordinateOptions.zCoordinates (1,:) = nan
end
obj.Coordinates = coordinates;
obj.x = coordinates(CoordinateOptions.xRowIndex, :);
obj.y = coordinates(CoordinateOptions.yRowIndex, :);
if isnan(CoordinateOptions.zRowIndex)
obj.z = nan;
else
obj.z = coordinates(CoordinateOptions.zRowIndex, :);
end
% If there are provided plotting coordinates, override with
% them
if ~isnan(CoordinateOptions.xCoordinates)
obj.x = CoordinateOptions.xCoordinates;
end
if ~isnan(CoordinateOptions.yCoordinates)
obj.y = CoordinateOptions.yCoordinates;
end
if ~isnan(CoordinateOptions.zCoordinates)
obj.z = CoordinateOptions.zCoordinates;
end
end
% Distance between two motor points is Euclidean distance
function dist = Distance(obj, otherMotorPoint)
SumOfSquares = 0;
for i = 1:length(otherMotorPoint.Coordinates)
SumOfSquares = SumOfSquares + (obj.Coordinates(i,1) - ...
otherMotorPoint.Coordinates(i,1))^2;
end
dist = sqrt(SumOfSquares);
end
% Find corresponding PerceptualPoint
function PPoint = FindPerceptualPoint(obj, SpaceTransformationToUse)
MotorCoordinates = obj.Coordinates;
PerceptualCoordinates = SpaceTransformationToUse.TransformationFunction(MotorCoordinates);
PPoint = PerceptualPoint(PerceptualCoordinates);
end
% Create a juncture with assumed mapping from FindPerceptualPoint
function juncture = MakeJuncture(obj, SpaceTransformationToUse)
PPoint = obj.FindPerceptualPoint(SpaceTransformationToUse);
juncture = Juncture(obj, PPoint);
end
end
end