-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpaceTransformation.m
More file actions
139 lines (134 loc) · 6.41 KB
/
SpaceTransformation.m
File metadata and controls
139 lines (134 loc) · 6.41 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Core Model, 2022
% Written by Maya Davis
% Concept by Maya Davis and Melissa A. Redford
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% METHOD LIST
% SpaceTransformation
% CreateCluster
% CreateSpace
%% CLASS DEFINITION
classdef SpaceTransformation
properties
TransformationFunction;
end
methods
% Creating an object
% EX: If TransformationFunction's name is ExampleFunction, then to
% make this object, you write NewSpaceTransformation =
% SpaceTransformation(@ExampleFunction).
function obj = SpaceTransformation(TransformationFunction)
obj.TransformationFunction = TransformationFunction;
end
function ResultingCluster = CreateCluster(obj, ...
MotorCoordinateMatrix, CoordinateOptions)
arguments
obj
MotorCoordinateMatrix (:,:) {mustBeNumeric}
CoordinateOptions.xMotorRowIndex {mustBeNumeric} = 1
CoordinateOptions.yMotorRowIndex {mustBeNumeric} = 2
CoordinateOptions.zMotorRowIndex {mustBeNumeric} = nan
CoordinateOptions.xPerceptualRowIndex {mustBeNumeric} = 1
CoordinateOptions.yPerceptualRowIndex {mustBeNumeric} = 2
CoordinateOptions.zPerceptualRowIndex {mustBeNumeric} = nan
end
%% Motor coordinate plotting info
% If xMotorRowIndex or yMotorRowIndex is nan, override it
if isnan(CoordinateOptions.xMotorRowIndex)
xMotorRowIndex = 1;
else
xMotorRowIndex = CoordinateOptions.xMotorRowIndex;
end
if isnan(CoordinateOptions.yMotorRowIndex)
yMotorRowIndex = 2;
else
yMotorRowIndex = CoordinateOptions.yMotorRowIndex;
end
zMotorRowIndex = CoordinateOptions.zMotorRowIndex;
%% Perceptual coordinate plotting info
% If xPerceptualRowIndex or yPerceptualRowIndex is nan, override it
if isnan(CoordinateOptions.xPerceptualRowIndex)
xPerceptualRowIndex = 1;
else
xPerceptualRowIndex = CoordinateOptions.xPerceptualRowIndex;
end
if isnan(CoordinateOptions.yPerceptualRowIndex)
yPerceptualRowIndex = 2;
else
yPerceptualRowIndex = CoordinateOptions.yPerceptualRowIndex;
end
zPerceptualRowIndex = CoordinateOptions.zPerceptualRowIndex;
%%
NumPerceptualDimensions = length(obj.TransformationFunction( ...
MotorCoordinateMatrix(:, 1)));
PerceptualCoordinateMatrix = nan(NumPerceptualDimensions, ...
size(MotorCoordinateMatrix, 2));
for p = 1:size(PerceptualCoordinateMatrix, 2)
PerceptualCoordinateMatrix(:, p) = obj.TransformationFunction(MotorCoordinateMatrix(:, p));
end
ResultingCluster = Cluster(MotorCoordinateMatrix, ...
PerceptualCoordinateMatrix, ...
"xMotorRowIndex", xMotorRowIndex, ...
"yMotorRowIndex", yMotorRowIndex, ...
"zMotorRowIndex", zMotorRowIndex, ...
"xPerceptualRowIndex", xPerceptualRowIndex, ...
"yPerceptualRowIndex", yPerceptualRowIndex, ...
"zPerceptualRowIndex", zPerceptualRowIndex);
end
% Making a space out of motor points & using this transformation
% EXAMPLE:
% TransformationFunction([x; y]) = [x - 2; y^2]
% MotorPointMatrixList = {[3 4 3; 4 4 5]; [6 6; 5 6]};
function ResultingSpace = CreateSpace(obj, ...
MotorCoordinateMatrixList, Options)
arguments
obj
MotorCoordinateMatrixList
Options.xMotorRowIndex {mustBeNumeric} = 1
Options.yMotorRowIndex {mustBeNumeric} = 2
Options.zMotorRowIndex {mustBeNumeric} = nan
Options.xPerceptualRowIndex {mustBeNumeric} = 1
Options.yPerceptualRowIndex {mustBeNumeric} = 2
Options.zPerceptualRowIndex {mustBeNumeric} = nan
Options.MaxDistanceWithActivationM {mustBeNumeric} = 10
Options.MaxDistanceWithActivationP {mustBeNumeric} = 10
end
ClusterList = Cluster.empty(0);
for cIndex = 1:length(MotorCoordinateMatrixList) % EX| cIndex = 1:2
CurrentMotorCoordinateMatrix = MotorCoordinateMatrixList{cIndex};
% EX| when cIndex = 1, CurrentMotorPointList =
% EX| [3 4 3; 4 4 5]
% EX| when cIndex = 2, CurrentMotorPointList =
% EX| [6 6; 5 6]
CurrentCluster = obj.CreateCluster( ...
CurrentMotorCoordinateMatrix, ...
"xMotorRowIndex", Options.xMotorRowIndex, ...
"yMotorRowIndex", Options.yMotorRowIndex, ...
"zMotorRowIndex", Options.zMotorRowIndex, ...
"xPerceptualRowIndex", Options.xPerceptualRowIndex, ...
"yPerceptualRowIndex", Options.yPerceptualRowIndex, ...
"zPerceptualRowIndex", Options.zPerceptualRowIndex);
ClusterList(cIndex) = CurrentCluster;
% EX| ClusterList(1) is ClusterA and
% EX| ClusterList(2) is ClusterB where these
% EX| clusters contain the junctures with the following
% EX| MotorPoint Coordinates (MPC) and PerceptualPoint
% EX| Coordinates (PPC):
% EX| ClusterA:
% EX| MPC = [3; 4] & PPC = [1; 16]
% EX| MPC = [4; 4] & PPC = [2; 16]
% EX| MPC = [3; 5] & PPC = [1; 25]
% EX| ClusterB:
% EX| MPC = [6; 5] & PPC = [4; 25]
% EX| MPC = [6; 6] & PPC = [4; 36]
end
ResultingSpace = Space(ClusterList, obj, ...
"MaxDistanceWithActivationM", ...
Options.MaxDistanceWithActivationM, ...
"MaxDistanceWithActivationP", ...
Options.MaxDistanceWithActivationP);
% EX| ResultingSpace.Clusters = [ClusterA ClusterB]
% EX| ResultingSpace.SpaceTransformation = obj
end
end
end