Skip to content

Commit f9643ed

Browse files
committed
feat: ProbeInsertion data model
1 parent 7aa3420 commit f9643ed

File tree

2 files changed

+61
-39
lines changed

2 files changed

+61
-39
lines changed

Assets/Scripts/Insertion/ProbeInsertion.cs

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,65 @@ public class ProbeInsertion
1818
public static HashSet<ProbeInsertion> Instances = new HashSet<ProbeInsertion>();
1919
#endregion
2020

21-
#region Coordinate vars
22-
public string AtlasName { get; set; }
23-
public string TransformName { get; set; }
21+
#region Data
22+
private InsertionData _data;
2423
#endregion
2524

26-
#region pos/angle vars
25+
#region Coordinate Properties
26+
public string AtlasName
27+
{
28+
get => _data.AtlasName;
29+
set => _data.AtlasName = value;
30+
}
31+
public string TransformName
32+
{
33+
get => _data.TransformName;
34+
set => _data.TransformName = value;
35+
}
36+
#endregion
37+
38+
#region Pos/Angle Properties
2739

28-
public float AP;
29-
public float ML;
30-
public float DV;
31-
public float Yaw;
32-
public float Pitch;
33-
public float Roll;
40+
public float AP
41+
{
42+
get => _data.APMLDV.x;
43+
set => _data.APMLDV.x = value;
44+
}
45+
public float ML
46+
{
47+
get => _data.APMLDV.y;
48+
set => _data.APMLDV.y = value;
49+
}
50+
public float DV
51+
{
52+
get => _data.APMLDV.z;
53+
set => _data.APMLDV.z = value;
54+
}
55+
public float Yaw
56+
{
57+
get => _data.Angles.x;
58+
set => _data.Angles.x = value;
59+
}
60+
public float Pitch
61+
{
62+
get => _data.Angles.y;
63+
set => _data.Angles.y = value;
64+
}
65+
public float Roll
66+
{
67+
get => _data.Angles.z;
68+
set => _data.Angles.z = value;
69+
}
3470

3571
/// <summary>
3672
/// The **transformed** coordinate in the active CoordinateSpace (AP, ML, DV)
3773
/// </summary>
3874
public Vector3 apmldv
3975
{
40-
get => new Vector3(AP, ML, DV);
76+
get => _data.APMLDV;
4177
set
4278
{
43-
AP = value.x;
44-
ML = value.y;
45-
DV = value.z;
79+
_data.APMLDV = value;
4680
}
4781
}
4882

@@ -51,12 +85,10 @@ public Vector3 apmldv
5185
/// </summary>
5286
public Vector3 angles
5387
{
54-
get => new(Yaw, Pitch, Roll);
88+
get => _data.Angles;
5589
set
5690
{
57-
Yaw = value.x;
58-
Pitch = value.y;
59-
Roll = value.z;
91+
_data.Angles = value;
6092
}
6193
}
6294
#endregion
@@ -66,14 +98,10 @@ public Vector3 angles
6698
public ProbeInsertion(float ap, float ml, float dv, float yaw, float pitch, float roll,
6799
string atlasName, string transformName)
68100
{
69-
this.AP = ap;
70-
this.ML = ml;
71-
this.DV = dv;
72-
this.Yaw = yaw;
73-
this.Pitch = pitch;
74-
this.Roll = roll;
75-
AtlasName = atlasName;
76-
TransformName = transformName;
101+
_data.APMLDV = new Vector3(ap, ml, dv);
102+
_data.Angles = new Vector3(yaw, pitch, roll);
103+
_data.AtlasName = atlasName;
104+
_data.TransformName = transformName;
77105
Instances.Add(this);
78106
}
79107

@@ -110,7 +138,7 @@ public ProbeInsertion(ProbeInsertion otherInsertion)
110138
/// <returns></returns>
111139
public Vector3 PositionSpaceU()
112140
{
113-
return BrainAtlasManager.ActiveAtlasTransform.T2U(apmldv);
141+
return BrainAtlasManager.ActiveAtlasTransform.T2U(_data.APMLDV);
114142
}
115143

116144
/// <summary>
@@ -119,23 +147,14 @@ public Vector3 PositionSpaceU()
119147
/// <returns></returns>
120148
public Vector3 PositionWorldT()
121149
{
122-
return BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(BrainAtlasManager.ActiveAtlasTransform.T2U_Vector(apmldv));
150+
return BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(BrainAtlasManager.ActiveAtlasTransform.T2U_Vector(_data.APMLDV));
123151
}
124152

125-
/// <summary>
126-
/// Get the corresponding **un-transformed** coordinate in World
127-
/// </summary>
128-
/// <returns></returns>
129153
public Vector3 PositionWorldU()
130154
{
131155
return BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(PositionSpaceU());
132156
}
133157

134-
/// <summary>
135-
/// Convert a world coordinate into the ProbeInsertion's transformed space
136-
/// </summary>
137-
/// <param name="coordWorld"></param>
138-
/// <returns></returns>
139158
public Vector3 World2T(Vector3 coordWorld)
140159
{
141160
return BrainAtlasManager.ActiveAtlasTransform.U2T(BrainAtlasManager.ActiveReferenceAtlas.World2Atlas(coordWorld));
@@ -157,6 +176,8 @@ public Vector3 T2World_Vector(Vector3 vectorT)
157176

158177
public override string ToString()
159178
{
160-
return JsonUtility.ToJson(this);
179+
// Store the current reference coordinate
180+
_data.ReferenceCoord = BrainAtlasManager.ActiveReferenceAtlas.AtlasSpace.ReferenceCoord;
181+
return JsonUtility.ToJson(_data);
161182
}
162183
}

Assets/Scripts/Insertion/trajectoryplanner.insertion.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"GUID:21a4085d3239a49479f839eb9996372e",
77
"GUID:0e68f56b71507ea46a7a7e86308f8eef",
88
"GUID:1487851fb22c2cc4a85babd43c153c20",
9-
"GUID:baba835d3f6de1948879ba12c4c45295"
9+
"GUID:baba835d3f6de1948879ba12c4c45295",
10+
"GUID:607bd5b74fabd34449aca1e00d3c898e"
1011
],
1112
"includePlatforms": [],
1213
"excludePlatforms": [],

0 commit comments

Comments
 (0)