mm_gps 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d298aac2aca73d83fc9191f83fac4742cf672d5
4
- data.tar.gz: 29f94747a2e57cafd333845eeb7ea26f03a69eb8
3
+ metadata.gz: 6caf7bc745f44789a88d5da54fc90055ec8739ef
4
+ data.tar.gz: f75f3b80c68f8e9cca6a5000e502398c4040b689
5
5
  SHA512:
6
- metadata.gz: b12093d8d971346ea2ee6955a8b432e09433ce4a187814cc7bc53fd2a54a3da25d19014a301fe89868e3a21a0d5dc0b721050b850c44dda5d51436a5028e0a78
7
- data.tar.gz: 3cca41dcc61d525fd2e47fd70a8fd2398c45ff2b4c6471c5cf7f3f84ddfb47b759b65d5b27dfbe9a9d853dcdc2741ecc7bdddbd38c47952ef0bc2681e367409a
6
+ metadata.gz: cc3f0816082666eab31c7246112b3f7364b252e2e888cf95b86529755d8408834873449f0144ea1ce00996c91414548e4c79349a2a4194459a28a11eb24db2b7
7
+ data.tar.gz: 8e5e7beef52535c074fad13583f8b3c4e546bc2eb1e8a5a1f6ddcf435978f9702a5d109c12444d7d8d075b79f5f59de968042849fd04fad12522ded1ce37ed92
data/README.md CHANGED
@@ -39,7 +39,7 @@ puts "Reading..."
39
39
  while not beacon.closed? do
40
40
  begin
41
41
  p beacon.get_packet
42
- rescue GPSException => e
42
+ rescue MmGPSException => e
43
43
  puts "Packet Error: #{e.inspect}"
44
44
  rescue IOError => e
45
45
  puts "Port closed? #{e.inspect}"
@@ -29,12 +29,22 @@ static ushort CRC16(const void *buf, ushort length) {
29
29
  return (ushort)crc.w;
30
30
  }
31
31
 
32
+ /* Calculate CRC16 checksum of a string
33
+ *
34
+ * @param buf [String] the string to be checksummed
35
+ * @return [Fixnum] the CRC16 value
36
+ */
32
37
  static VALUE mm_gps_CRC16(VALUE klass, VALUE str)
33
38
  {
34
39
  Check_Type(str, T_STRING);
35
40
  return rb_fix_new(CRC16(RSTRING_PTR(str), RSTRING_LEN(str)));
36
41
  }
37
42
 
43
+ /* Appends a CRC16 checksum to a string
44
+ *
45
+ * @param buf [String] the starting string
46
+ * @return [String] the original string plus its CRC16
47
+ */
38
48
  static VALUE mm_gps_add_CRC16(VALUE klass, VALUE str)
39
49
  {
40
50
  union {
@@ -0,0 +1,1777 @@
1
+ (* Content-type: application/vnd.wolfram.mathematica *)
2
+
3
+ (*** Wolfram Notebook File ***)
4
+ (* http://www.wolfram.com/nb *)
5
+
6
+ (* CreatedBy='Mathematica 11.0' *)
7
+
8
+ (*CacheID: 234*)
9
+ (* Internal cache information:
10
+ NotebookFileLineBreakTest
11
+ NotebookFileLineBreakTest
12
+ NotebookDataPosition[ 158, 7]
13
+ NotebookDataLength[ 66457, 1769]
14
+ NotebookOptionsPosition[ 64436, 1697]
15
+ NotebookOutlinePosition[ 64818, 1714]
16
+ CellTagsIndexPosition[ 64775, 1711]
17
+ WindowFrame->Normal*)
18
+
19
+ (* Beginning of Notebook Content *)
20
+ Notebook[{
21
+
22
+ Cell[CellGroupData[{
23
+ Cell["Coordinates transformation", "Title",
24
+ CellChangeTimes->{{3.680517689924705*^9, 3.680517695145154*^9}}],
25
+
26
+ Cell["\<\
27
+ This worksheet shows how to recall the equations needed for performing the \
28
+ coordinates transformation that gives the coordinates of a {X,Y,Z} point in a \
29
+ local reference frame that is centered on the point p1, has the X axis \
30
+ pointing towards p2, and the Y axis lying in the plane {p1,p2,p3}.
31
+ First, let\[CloseCurlyQuote]s set up a test environment: beacons are the \
32
+ three coordinates used by MarvelMind Dashboard for defining the global \
33
+ reference frame when setting up the system, while dots is a list of random \
34
+ points, whose first three elements (non-collinear!) are to be used for \
35
+ setting the new local reference frame.\
36
+ \>", "Text",
37
+ CellChangeTimes->{{3.680517702402617*^9, 3.680518013874937*^9}}],
38
+
39
+ Cell[CellGroupData[{
40
+
41
+ Cell["Rationale", "Chapter",
42
+ CellChangeTimes->{{3.6805184378507147`*^9, 3.680518439087364*^9}}],
43
+
44
+ Cell[BoxData[{
45
+ RowBox[{
46
+ RowBox[{"r", " ", "=", " ", "0.05"}], ";"}], "\[IndentingNewLine]",
47
+ RowBox[{
48
+ RowBox[{"h", " ", "=", " ",
49
+ RowBox[{"-", "0.4"}]}], ";"}], "\[IndentingNewLine]",
50
+ RowBox[{
51
+ RowBox[{"pts", " ", "=", " ",
52
+ RowBox[{"{",
53
+ RowBox[{
54
+ RowBox[{"{",
55
+ RowBox[{"0", ",", "0", ",", "h"}], "}"}], ",", " ",
56
+ RowBox[{"{",
57
+ RowBox[{"1", ",", " ", "0", ",", " ", "h"}], "}"}], ",", " ",
58
+ RowBox[{"{",
59
+ RowBox[{"0.01", ",", " ", "0.8", ",", " ", "h"}], "}"}]}], "}"}]}],
60
+ ";"}], "\[IndentingNewLine]",
61
+ RowBox[{
62
+ RowBox[{"beacons", " ", "=", " ",
63
+ RowBox[{"{",
64
+ RowBox[{"Red", ",", " ",
65
+ RowBox[{"Sphere", "[",
66
+ RowBox[{
67
+ RowBox[{"pts", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
68
+ ",", " ", "r"}], "]"}], ",", "Green", ",", " ",
69
+ RowBox[{"Sphere", "[",
70
+ RowBox[{
71
+ RowBox[{"pts", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}],
72
+ ",", " ", "r"}], "]"}], ",", " ", "Blue", ",", " ",
73
+ RowBox[{"Sphere", "[",
74
+ RowBox[{
75
+ RowBox[{"pts", "\[LeftDoubleBracket]", "3", "\[RightDoubleBracket]"}],
76
+ ",", " ", "r"}], "]"}]}], "}"}]}], ";"}]}], "Input",
77
+ CellChangeTimes->{{3.6804983965853033`*^9, 3.680498476333729*^9}, {
78
+ 3.680498884211503*^9, 3.68049893827804*^9}, {3.6804990785932913`*^9,
79
+ 3.680499080832478*^9}, {3.680499128619952*^9, 3.680499140882655*^9}, {
80
+ 3.680499215889431*^9, 3.680499228873247*^9}, 3.680499613257606*^9, {
81
+ 3.680499647615479*^9, 3.68049977514625*^9}, {3.68049991096002*^9,
82
+ 3.680499934043716*^9}, 3.6805046536248703`*^9}],
83
+
84
+ Cell[BoxData[
85
+ RowBox[{
86
+ RowBox[{"dots", " ", "=", " ",
87
+ RowBox[{"{",
88
+ RowBox[{
89
+ RowBox[{"{",
90
+ RowBox[{"0.3", ",", " ", "0.2", ",", " ", "0"}], "}"}], ",", " ",
91
+ RowBox[{"{",
92
+ RowBox[{"0.33", ",", " ", "0.15", ",", " ", "0"}], "}"}], ",", " ",
93
+ RowBox[{"{",
94
+ RowBox[{"0.45", ",", " ", "0.4", ",", " ", "0.1"}], "}"}], ",",
95
+ RowBox[{"{",
96
+ RowBox[{"0.48", ",", " ", "0.56", ",", " ", "0.2"}], "}"}]}], "}"}]}],
97
+ ";"}]], "Input",
98
+ CellChangeTimes->{{3.6805001468941717`*^9, 3.680500215331265*^9}}],
99
+
100
+ Cell[CellGroupData[{
101
+
102
+ Cell[BoxData[
103
+ RowBox[{"Graphics3D", "[",
104
+ RowBox[{
105
+ RowBox[{"{",
106
+ RowBox[{"beacons", ",", " ", "Orange", ",", " ",
107
+ RowBox[{"Point", "[", "dots", "]"}]}], "}"}], ",", " ",
108
+ RowBox[{"Axes", "->", "True"}], ",", " ",
109
+ RowBox[{"AxesLabel", "\[Rule]",
110
+ RowBox[{"{",
111
+ RowBox[{"\"\<X\>\"", ",", " ", "\"\<Y\>\"", ",", " ", "\"\<Z\>\""}],
112
+ "}"}]}], ",", " ",
113
+ RowBox[{"PlotRange", "\[Rule]",
114
+ RowBox[{"{",
115
+ RowBox[{
116
+ RowBox[{"-", "0.5"}], ",", "0.5"}], "}"}]}]}], "]"}]], "Input",
117
+ CellChangeTimes->{{3.680498509965493*^9, 3.680498529434538*^9}, {
118
+ 3.6804986007735147`*^9, 3.680498674900194*^9}, {3.680498731928502*^9,
119
+ 3.680498740285985*^9}, {3.680498947381124*^9, 3.680498980152439*^9}, {
120
+ 3.6804990643608522`*^9, 3.680499090910636*^9}, {3.6804991495361567`*^9,
121
+ 3.680499149593378*^9}, 3.680499239604892*^9, {3.680499295686363*^9,
122
+ 3.680499457149255*^9}, {3.6804995066623583`*^9, 3.680499588752989*^9}, {
123
+ 3.680500225043283*^9, 3.680500248454371*^9}, {3.680500727498269*^9,
124
+ 3.6805007288600063`*^9}}],
125
+
126
+ Cell[BoxData[
127
+ Graphics3DBox[{{
128
+ {RGBColor[1, 0, 0], SphereBox[{0, 0, -0.4}, 0.05]},
129
+ {RGBColor[0, 1, 0], SphereBox[{1, 0, -0.4}, 0.05]},
130
+ {RGBColor[0, 0, 1], SphereBox[{0.01, 0.8, -0.4}, 0.05]}},
131
+ {RGBColor[1, 0.5, 0],
132
+ Point3DBox[{{0.3, 0.2, 0}, {0.33, 0.15, 0}, {0.45, 0.4, 0.1}, {0.48, 0.56,
133
+ 0.2}}]}},
134
+ Axes->True,
135
+ AxesLabel->{
136
+ FormBox["\"X\"", TraditionalForm],
137
+ FormBox["\"Y\"", TraditionalForm],
138
+ FormBox["\"Z\"", TraditionalForm]},
139
+ ImageSize->{504.9258510440578, 330.},
140
+ PlotRange->{-0.5, 0.5},
141
+ ViewPoint->{0.07569213541230002, -0.4960293560872875, 3.3463749907230005`},
142
+ ViewVertical->{0.017778090489962935`, 0.5570766698033633,
143
+ 1.0196882873425608`}]], "Output",
144
+ CellChangeTimes->{{3.680498622671494*^9, 3.680498650335835*^9},
145
+ 3.680498740928894*^9, {3.680498963865217*^9, 3.680498981948889*^9}, {
146
+ 3.6804990674584303`*^9, 3.680499092686059*^9}, {3.680499135825762*^9,
147
+ 3.68049914516775*^9}, {3.6804992326357822`*^9, 3.680499239893326*^9},
148
+ 3.6804993036932793`*^9, {3.6804993350493307`*^9, 3.680499408915601*^9}, {
149
+ 3.680499439538013*^9, 3.68049945785085*^9}, {3.680499513677005*^9,
150
+ 3.6804996168537903`*^9}, {3.6804997143817263`*^9, 3.680499747436201*^9},
151
+ 3.680499778823763*^9, 3.680499936708745*^9, {3.680500238497197*^9,
152
+ 3.680500249159938*^9}, 3.6805007296067867`*^9, 3.680502455410474*^9,
153
+ 3.680504658104538*^9}]
154
+ }, Open ]],
155
+
156
+ Cell["\<\
157
+ The transformation happens in three steps:
158
+ 1. p1 is translated into the origin
159
+ 2. rotation about Z so that p2 is aligned to X axis (angle a1)
160
+ 3. rotation about X so that p3 lays on the XY plane (angle a2)
161
+ Note that a2 is calculated as the angle of the projection of p3 on YZ plane \
162
+ (updated after T0 and T1) and the Y plane.\
163
+ \>", "Text",
164
+ CellChangeTimes->{{3.680518041000066*^9, 3.6805180932672367`*^9}, {
165
+ 3.680518137110448*^9, 3.6805182237920933`*^9}, {3.680518264766864*^9,
166
+ 3.680518275779542*^9}, {3.680518313029077*^9, 3.68051838828137*^9}}],
167
+
168
+ Cell[CellGroupData[{
169
+
170
+ Cell[BoxData[{
171
+ RowBox[{
172
+ RowBox[{"T0", " ", "=", " ",
173
+ RowBox[{"InverseFunction", "[",
174
+ RowBox[{"TranslationTransform", "[",
175
+ RowBox[{"dots", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
176
+ "]"}], "]"}]}], ";"}], "\[IndentingNewLine]",
177
+ RowBox[{
178
+ RowBox[{"a1", " ", "=",
179
+ RowBox[{"VectorAngle", "[",
180
+ RowBox[{
181
+ RowBox[{
182
+ RowBox[{"dots", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}],
183
+ "//", "T0"}], ",",
184
+ RowBox[{"{",
185
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "]"}]}],
186
+ ";"}], "\[IndentingNewLine]",
187
+ RowBox[{
188
+ RowBox[{"T1", "=",
189
+ RowBox[{"RotationTransform", "[",
190
+ RowBox[{"a1", ",",
191
+ RowBox[{"{",
192
+ RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "]"}]}],
193
+ ";"}], "\[IndentingNewLine]",
194
+ RowBox[{
195
+ RowBox[{"a2", "=",
196
+ RowBox[{"VectorAngle", "[",
197
+ RowBox[{
198
+ RowBox[{
199
+ RowBox[{"(",
200
+ RowBox[{
201
+ RowBox[{
202
+ "dots", "\[LeftDoubleBracket]", "3", "\[RightDoubleBracket]"}], "//",
203
+
204
+ RowBox[{"RightComposition", "[",
205
+ RowBox[{"T0", ",", " ", "T1"}], "]"}]}], ")"}], "*", " ",
206
+ RowBox[{"{",
207
+ RowBox[{"0", ",", " ", "1", ",", " ", "1"}], "}"}]}], ",",
208
+ RowBox[{"{",
209
+ RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], "]"}]}],
210
+ ";"}], "\[IndentingNewLine]",
211
+ RowBox[{
212
+ RowBox[{"T2", "=",
213
+ RowBox[{"RotationTransform", "[",
214
+ RowBox[{
215
+ RowBox[{"-", "a2"}], ",", " ",
216
+ RowBox[{"{",
217
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "]"}]}],
218
+ ";"}], "\[IndentingNewLine]",
219
+ RowBox[{"Graphics3D", "[",
220
+ RowBox[{
221
+ RowBox[{"{", "\[IndentingNewLine]",
222
+ RowBox[{"beacons", ",", " ", "\[IndentingNewLine]", "Orange", ",", " ",
223
+ RowBox[{"Point", "[", "dots", "]"}], ",", " ", "\[IndentingNewLine]",
224
+ "Blue", ",", " ",
225
+ RowBox[{"Point", "[",
226
+ RowBox[{"dots", "//", "T0"}], "]"}], ",", "\[IndentingNewLine]",
227
+ "Green", ",", " ",
228
+ RowBox[{"Point", "[",
229
+ RowBox[{"dots", "//",
230
+ RowBox[{"RightComposition", "[",
231
+ RowBox[{"T0", ",", " ", "T1"}], "]"}]}], "]"}], ",",
232
+ "\[IndentingNewLine]", "Red", ",",
233
+ RowBox[{"Opacity", "[", "0.5", "]"}], ",", " ",
234
+ RowBox[{"PointSize", "[", "Large", "]"}], ",",
235
+ RowBox[{"Point", "[",
236
+ RowBox[{"dots", "//",
237
+ RowBox[{"RightComposition", "[",
238
+ RowBox[{"T0", ",", " ", "T1", ",", " ", "T2"}], "]"}]}], "]"}], ",",
239
+ "\[IndentingNewLine]", "Green", ",", "\[IndentingNewLine]",
240
+ RowBox[{"Opacity", "[", "0.01", "]"}], ",",
241
+ RowBox[{"InfinitePlane", "[",
242
+ RowBox[{"{",
243
+ RowBox[{
244
+ RowBox[{"{",
245
+ RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",",
246
+ RowBox[{"{",
247
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",",
248
+ RowBox[{"{",
249
+ RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "}"}], "]"}], ",",
250
+ "\[IndentingNewLine]",
251
+ RowBox[{"Opacity", "[", "0.01", "]"}], ",",
252
+ RowBox[{"InfinitePlane", "[",
253
+ RowBox[{"{",
254
+ RowBox[{
255
+ RowBox[{"{",
256
+ RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",",
257
+ RowBox[{"{",
258
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",",
259
+ RowBox[{"{",
260
+ RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], "}"}], "]"}]}],
261
+ "\[IndentingNewLine]", "}"}], ",", " ",
262
+ RowBox[{"Axes", "->", "True"}], ",", " ",
263
+ RowBox[{"AxesLabel", "\[Rule]",
264
+ RowBox[{"{",
265
+ RowBox[{"\"\<X\>\"", ",", " ", "\"\<Y\>\"", ",", " ", "\"\<Z\>\""}],
266
+ "}"}]}], ",", " ",
267
+ RowBox[{"PlotRange", "\[Rule]",
268
+ RowBox[{"{",
269
+ RowBox[{
270
+ RowBox[{"-", "0.5"}], ",", "0.5"}], "}"}]}]}],
271
+ "]"}], "\[IndentingNewLine]",
272
+ RowBox[{"dots", "//",
273
+ RowBox[{"RightComposition", "[",
274
+ RowBox[{"T0", ",", " ", "T1", ",", "T2"}],
275
+ "]"}]}], "\[IndentingNewLine]",
276
+ RowBox[{
277
+ RowBox[{"TransformationMatrix", "[",
278
+ RowBox[{"RightComposition", "[",
279
+ RowBox[{"T0", ",", " ", "T1", ",", "T2"}], "]"}], "]"}], "//",
280
+ "MatrixForm"}]}], "Input",
281
+ CellChangeTimes->{{3.680507291448778*^9, 3.680507393352105*^9}, {
282
+ 3.68050746432998*^9, 3.6805074692124453`*^9}, {3.680507738700568*^9,
283
+ 3.68050774096172*^9}, {3.680507772430007*^9, 3.6805077957833633`*^9}, {
284
+ 3.6805079245990753`*^9, 3.680508061794066*^9}, 3.680508105807659*^9, {
285
+ 3.680508174388838*^9, 3.6805081753195467`*^9}, {3.6805082189483843`*^9,
286
+ 3.6805082416788263`*^9}, {3.6805082927767143`*^9,
287
+ 3.6805082989154778`*^9}, {3.6805083871421824`*^9, 3.680508461738461*^9}, {
288
+ 3.680508921294106*^9, 3.68050892278564*^9}}],
289
+
290
+ Cell[BoxData[
291
+ Graphics3DBox[{{
292
+ {RGBColor[1, 0, 0], SphereBox[{0, 0, -0.4}, 0.05]},
293
+ {RGBColor[0, 1, 0], SphereBox[{1, 0, -0.4}, 0.05]},
294
+ {RGBColor[0, 0, 1], SphereBox[{0.01, 0.8, -0.4}, 0.05]}},
295
+ {RGBColor[1, 0.5, 0],
296
+ Point3DBox[{{0.3, 0.2, 0}, {0.33, 0.15, 0}, {0.45, 0.4, 0.1}, {0.48, 0.56,
297
+ 0.2}}]},
298
+ {RGBColor[0, 0, 1],
299
+ Point3DBox[{{0., 0., 0.}, {0.030000000000000027`, -0.05000000000000002,
300
+ 0.}, {0.15000000000000002`, 0.2, 0.1}, {0.18, 0.36000000000000004`,
301
+ 0.2}}]},
302
+ {RGBColor[0, 1, 0],
303
+ Point3DBox[{{0., 0., 0.}, {0.058309518948453015`, -5.551115123125783*^-17,
304
+ 0.}, {-0.0943242218283798, 0.23152308994238696`,
305
+ 0.1}, {-0.21608821727956112`, 0.3395671985821675, 0.2}}]},
306
+ {RGBColor[1, 0, 0], PointSize[Large], Opacity[0.5],
307
+ Point3DBox[{{0., -5.551115123125783*^-17, 0.}, {0.058309518948453015`, 0.,
308
+ 0.}, {-0.0943242218283798,
309
+ 0.25219623545261455`, -1.1102230246251565`*^-16}, {-0.21608821727956112`,
310
+ 0.39103536530525623`, 0.048961468866099145`}}],
311
+ {RGBColor[0, 1, 0], Opacity[0.01],
312
+ TagBox[ConicHullRegion3DBox[{{0, 0, 0}, {1, 0, 0}, {0, 0, 1}}],
313
+ "InfinitePlane"],
314
+ {Opacity[0.01],
315
+ TagBox[ConicHullRegion3DBox[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}],
316
+ "InfinitePlane"]}}}},
317
+ Axes->True,
318
+ AxesLabel->{
319
+ FormBox["\"X\"", TraditionalForm],
320
+ FormBox["\"Y\"", TraditionalForm],
321
+ FormBox["\"Z\"", TraditionalForm]},
322
+ ImageSize->{692.9998987474303, 616.},
323
+ PlotRange->{-0.5, 0.5},
324
+ ViewPoint->{-0.14510733139987664`, -1.1527872585156027`,
325
+ 3.1780537124123764`},
326
+ ViewVertical->{-0.08993959998162543, 0.781362803714105,
327
+ 1.0902648440379616`}]], "Output",
328
+ CellChangeTimes->{
329
+ 3.680507470412012*^9, 3.680507959302704*^9, {3.680507990863638*^9,
330
+ 3.6805080369794197`*^9}, {3.6805080893388233`*^9, 3.680508106989883*^9},
331
+ 3.680508176119774*^9, {3.680508232080171*^9, 3.680508242241768*^9},
332
+ 3.6805083002634687`*^9, 3.680508404281156*^9, {3.680508436978293*^9,
333
+ 3.680508462500139*^9}, 3.6805089244402447`*^9}],
334
+
335
+ Cell[BoxData[
336
+ RowBox[{"{",
337
+ RowBox[{
338
+ RowBox[{"{",
339
+ RowBox[{"0.`", ",",
340
+ RowBox[{"-", "5.551115123125783`*^-17"}], ",", "0.`"}], "}"}], ",",
341
+ RowBox[{"{",
342
+ RowBox[{"0.058309518948453015`", ",", "0.`", ",", "0.`"}], "}"}], ",",
343
+ RowBox[{"{",
344
+ RowBox[{
345
+ RowBox[{"-", "0.0943242218283798`"}], ",", "0.25219623545261455`", ",",
346
+ RowBox[{"-", "1.1102230246251565`*^-16"}]}], "}"}], ",",
347
+ RowBox[{"{",
348
+ RowBox[{
349
+ RowBox[{"-", "0.21608821727956112`"}], ",", "0.39103536530525623`", ",",
350
+ "0.048961468866099145`"}], "}"}]}], "}"}]], "Output",
351
+ CellChangeTimes->{
352
+ 3.680507470412012*^9, 3.680507959302704*^9, {3.680507990863638*^9,
353
+ 3.6805080369794197`*^9}, {3.6805080893388233`*^9, 3.680508106989883*^9},
354
+ 3.680508176119774*^9, {3.680508232080171*^9, 3.680508242241768*^9},
355
+ 3.6805083002634687`*^9, 3.680508404281156*^9, {3.680508436978293*^9,
356
+ 3.680508462500139*^9}, 3.6805089244498262`*^9}],
357
+
358
+ Cell[BoxData[
359
+ TagBox[
360
+ RowBox[{"(", "\[NoBreak]", GridBox[{
361
+ {"0.5144957554275267`",
362
+ RowBox[{"-", "0.8574929257125441`"}], "0.`", "0.017149858514250826`"},
363
+ {"0.7872021222220336`", "0.4723212733332204`", "0.3965166245266544`",
364
+ RowBox[{"-", "0.3306248913332542`"}]},
365
+ {
366
+ RowBox[{"-", "0.34001020045902325`"}],
367
+ RowBox[{"-", "0.204006120275414`"}], "0.9180275412393618`",
368
+ "0.1428042841927898`"},
369
+ {"0.`", "0.`", "0.`", "1.`"}
370
+ },
371
+ GridBoxAlignment->{
372
+ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}},
373
+ "RowsIndexed" -> {}},
374
+ GridBoxSpacings->{"Columns" -> {
375
+ Offset[0.27999999999999997`], {
376
+ Offset[0.7]},
377
+ Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
378
+ Offset[0.2], {
379
+ Offset[0.4]},
380
+ Offset[0.2]}, "RowsIndexed" -> {}}], "\[NoBreak]", ")"}],
381
+ Function[BoxForm`e$,
382
+ MatrixForm[BoxForm`e$]]]], "Output",
383
+ CellChangeTimes->{
384
+ 3.680507470412012*^9, 3.680507959302704*^9, {3.680507990863638*^9,
385
+ 3.6805080369794197`*^9}, {3.6805080893388233`*^9, 3.680508106989883*^9},
386
+ 3.680508176119774*^9, {3.680508232080171*^9, 3.680508242241768*^9},
387
+ 3.6805083002634687`*^9, 3.680508404281156*^9, {3.680508436978293*^9,
388
+ 3.680508462500139*^9}, 3.680508924455805*^9}]
389
+ }, Open ]]
390
+ }, Open ]],
391
+
392
+ Cell[CellGroupData[{
393
+
394
+ Cell["Generalization", "Chapter",
395
+ CellChangeTimes->{{3.68051845213846*^9, 3.680518456063743*^9}}],
396
+
397
+ Cell["\<\
398
+ We now repeat the above for three general points p1, p2, and p3.\
399
+ \>", "Text",
400
+ CellChangeTimes->{{3.680518468123962*^9, 3.6805184903207293`*^9}}],
401
+
402
+ Cell[BoxData[{
403
+ RowBox[{"Clear", "[",
404
+ RowBox[{"T0", ",", "T1", ",", "T2", ",", " ", "a1", ",", " ", "a2"}],
405
+ "]"}], "\[IndentingNewLine]",
406
+ RowBox[{
407
+ RowBox[{
408
+ RowBox[{"T0", "[", "p_", "]"}], " ", ":=", " ",
409
+ RowBox[{"InverseFunction", "[",
410
+ RowBox[{"TranslationTransform", "[", "p", "]"}], "]"}]}],
411
+ ";"}], "\[IndentingNewLine]",
412
+ RowBox[{
413
+ RowBox[{
414
+ RowBox[{"a1", "[",
415
+ RowBox[{"p1_", ",", " ", "p2_"}], "]"}], " ", ":=",
416
+ RowBox[{"VectorAngle", "[",
417
+ RowBox[{
418
+ RowBox[{"p2", "//",
419
+ RowBox[{"T0", "[", "p1", "]"}]}], ",",
420
+ RowBox[{"{",
421
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "]"}]}],
422
+ ";"}], "\[IndentingNewLine]",
423
+ RowBox[{
424
+ RowBox[{
425
+ RowBox[{"T1", "[",
426
+ RowBox[{"p1_", ",", "p2_"}], "]"}], ":=",
427
+ RowBox[{"RotationTransform", "[",
428
+ RowBox[{
429
+ RowBox[{"a1", "[",
430
+ RowBox[{"p1", ",", "p2"}], "]"}], ",",
431
+ RowBox[{"{",
432
+ RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "]"}]}],
433
+ ";"}], "\[IndentingNewLine]",
434
+ RowBox[{
435
+ RowBox[{
436
+ RowBox[{"a2", "[",
437
+ RowBox[{"p1_", ",", "p2_", ",", "p3_"}], "]"}], ":=",
438
+ RowBox[{"VectorAngle", "[",
439
+ RowBox[{
440
+ RowBox[{
441
+ RowBox[{"(",
442
+ RowBox[{"p3", "//",
443
+ RowBox[{"RightComposition", "[",
444
+ RowBox[{
445
+ RowBox[{"T0", "[", "p1", "]"}], ",", " ",
446
+ RowBox[{"T1", "[",
447
+ RowBox[{"p1", ",", "p2"}], "]"}]}], "]"}]}], ")"}], "*", " ",
448
+ RowBox[{"{",
449
+ RowBox[{"0", ",", " ", "1", ",", " ", "1"}], "}"}]}], ",",
450
+ RowBox[{"{",
451
+ RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], "]"}]}],
452
+ ";"}], "\[IndentingNewLine]",
453
+ RowBox[{
454
+ RowBox[{
455
+ RowBox[{"T2", "[",
456
+ RowBox[{"p1_", ",", "p2_", ",", "p3_"}], "]"}], ":=",
457
+ RowBox[{"RotationTransform", "[",
458
+ RowBox[{
459
+ RowBox[{"-",
460
+ RowBox[{"a2", "[",
461
+ RowBox[{"p1", ",", "p2", ",", "p3"}], "]"}]}], ",", " ",
462
+ RowBox[{"{",
463
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "]"}]}],
464
+ ";"}], "\[IndentingNewLine]",
465
+ RowBox[{
466
+ RowBox[{"TT", "[",
467
+ RowBox[{"p1_", ",", "p2_", ",", "p3_"}], "]"}], ":=",
468
+ RowBox[{"RightComposition", "[",
469
+ RowBox[{
470
+ RowBox[{"T0", "[", "p1", "]"}], ",",
471
+ RowBox[{"T1", "[",
472
+ RowBox[{"p1", ",", "p2"}], "]"}], ",",
473
+ RowBox[{"T2", "[",
474
+ RowBox[{"p1", ",", "p2", ",", "p3"}], "]"}]}], "]"}]}]}], "Input",
475
+ CellChangeTimes->{{3.6805085122429943`*^9, 3.6805085183050413`*^9}, {
476
+ 3.680508554970911*^9, 3.680508756561604*^9}, {3.6805092767419767`*^9,
477
+ 3.68050928415315*^9}, {3.680509389727222*^9, 3.680509405104436*^9}, {
478
+ 3.680509669316807*^9, 3.680509727108163*^9}}],
479
+
480
+ Cell["Now check for consistency with the above on the same data:", "Text",
481
+ CellChangeTimes->{{3.680518527086228*^9, 3.680518540091634*^9}}],
482
+
483
+ Cell[CellGroupData[{
484
+
485
+ Cell[BoxData[
486
+ RowBox[{"Graphics3D", "[",
487
+ RowBox[{
488
+ RowBox[{"{", "\[IndentingNewLine]",
489
+ RowBox[{"beacons", ",", " ", "\[IndentingNewLine]", "Orange", ",", " ",
490
+ RowBox[{"Point", "[", "dots", "]"}], ",", " ", "\[IndentingNewLine]",
491
+ "Blue", ",", " ",
492
+ RowBox[{"Point", "[",
493
+ RowBox[{"dots", "//",
494
+ RowBox[{"T0", "[",
495
+ RowBox[{
496
+ "dots", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
497
+ "]"}]}], "]"}], ",", "\[IndentingNewLine]", "Green", ",", " ",
498
+ RowBox[{"Point", "[",
499
+ RowBox[{"dots", "//",
500
+ RowBox[{"RightComposition", "[",
501
+ RowBox[{
502
+ RowBox[{"T0", "[",
503
+ RowBox[{
504
+ "dots", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
505
+ "]"}], ",", " ",
506
+ RowBox[{"T1", "[",
507
+ RowBox[{
508
+ RowBox[{
509
+ "dots", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
510
+ ",",
511
+ RowBox[{
512
+ "dots", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}]}],
513
+ "]"}]}], "]"}]}], "]"}], ",", "\[IndentingNewLine]", "Red", ",",
514
+ RowBox[{"Opacity", "[", "0.5", "]"}], ",", " ",
515
+ RowBox[{"PointSize", "[", "Large", "]"}], ",",
516
+ RowBox[{"Point", "[",
517
+ RowBox[{"dots", "//",
518
+ RowBox[{"TT", "[",
519
+ RowBox[{
520
+ RowBox[{
521
+ "dots", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], ",",
522
+
523
+ RowBox[{
524
+ "dots", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], ",",
525
+
526
+ RowBox[{
527
+ "dots", "\[LeftDoubleBracket]", "3", "\[RightDoubleBracket]"}]}],
528
+ "]"}]}], "]"}], ",", "\[IndentingNewLine]", "Green", ",",
529
+ "\[IndentingNewLine]",
530
+ RowBox[{"Opacity", "[", "0.01", "]"}], ",",
531
+ RowBox[{"InfinitePlane", "[",
532
+ RowBox[{"{",
533
+ RowBox[{
534
+ RowBox[{"{",
535
+ RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",",
536
+ RowBox[{"{",
537
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",",
538
+ RowBox[{"{",
539
+ RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "}"}], "]"}], ",",
540
+ "\[IndentingNewLine]",
541
+ RowBox[{"Opacity", "[", "0.01", "]"}], ",",
542
+ RowBox[{"InfinitePlane", "[",
543
+ RowBox[{"{",
544
+ RowBox[{
545
+ RowBox[{"{",
546
+ RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",",
547
+ RowBox[{"{",
548
+ RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",",
549
+ RowBox[{"{",
550
+ RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], "}"}], "]"}]}],
551
+ "\[IndentingNewLine]", "}"}], ",", " ",
552
+ RowBox[{"Axes", "->", "True"}], ",", " ",
553
+ RowBox[{"AxesLabel", "\[Rule]",
554
+ RowBox[{"{",
555
+ RowBox[{"\"\<X\>\"", ",", " ", "\"\<Y\>\"", ",", " ", "\"\<Z\>\""}],
556
+ "}"}]}], ",", " ",
557
+ RowBox[{"PlotRange", "\[Rule]",
558
+ RowBox[{"{",
559
+ RowBox[{
560
+ RowBox[{"-", "0.5"}], ",", "0.5"}], "}"}]}]}], "]"}]], "Input",
561
+ CellChangeTimes->{{3.6805144870615997`*^9, 3.680514505982815*^9}}],
562
+
563
+ Cell[BoxData[
564
+ Graphics3DBox[{{
565
+ {RGBColor[1, 0, 0], SphereBox[{0, 0, -0.4}, 0.05]},
566
+ {RGBColor[0, 1, 0], SphereBox[{1, 0, -0.4}, 0.05]},
567
+ {RGBColor[0, 0, 1], SphereBox[{0.01, 0.8, -0.4}, 0.05]}},
568
+ {RGBColor[1, 0.5, 0],
569
+ Point3DBox[{{0.3, 0.2, 0}, {0.33, 0.15, 0}, {0.45, 0.4, 0.1}, {0.48, 0.56,
570
+ 0.2}}]},
571
+ {RGBColor[0, 0, 1],
572
+ Point3DBox[{{0., 0., 0.}, {0.030000000000000027`, -0.05000000000000002,
573
+ 0.}, {0.15000000000000002`, 0.2, 0.1}, {0.18, 0.36000000000000004`,
574
+ 0.2}}]},
575
+ {RGBColor[0, 1, 0],
576
+ Point3DBox[{{0., 0., 0.}, {0.058309518948453015`, -5.551115123125783*^-17,
577
+ 0.}, {-0.0943242218283798, 0.23152308994238696`,
578
+ 0.1}, {-0.21608821727956112`, 0.3395671985821675, 0.2}}]},
579
+ {RGBColor[1, 0, 0], PointSize[Large], Opacity[0.5],
580
+ Point3DBox[{{0., -5.551115123125783*^-17, 0.}, {0.058309518948453015`, 0.,
581
+ 0.}, {-0.0943242218283798,
582
+ 0.25219623545261455`, -1.1102230246251565`*^-16}, {-0.21608821727956112`,
583
+ 0.39103536530525623`, 0.048961468866099145`}}],
584
+ {RGBColor[0, 1, 0], Opacity[0.01],
585
+ TagBox[ConicHullRegion3DBox[{{0, 0, 0}, {1, 0, 0}, {0, 0, 1}}],
586
+ "InfinitePlane"],
587
+ {Opacity[0.01],
588
+ TagBox[ConicHullRegion3DBox[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}],
589
+ "InfinitePlane"]}}}},
590
+ Axes->True,
591
+ AxesLabel->{
592
+ FormBox["\"X\"", TraditionalForm],
593
+ FormBox["\"Y\"", TraditionalForm],
594
+ FormBox["\"Z\"", TraditionalForm]},
595
+ ImageSize->{325.8705609708621, 298.1810922526852},
596
+ PlotRange->{-0.5, 0.5},
597
+ ViewPoint->{0.5246505894953131, -2.976974674646756, 1.5206457659343493`},
598
+ ViewVertical->{0.001164978200953383, -0.23645307375499894`,
599
+ 1.300077643990591}]], "Output",
600
+ CellChangeTimes->{{3.680509341675922*^9, 3.68050935778759*^9},
601
+ 3.6805145092851954`*^9}]
602
+ }, Open ]],
603
+
604
+ Cell[TextData[{
605
+ "The TransformationFunction ",
606
+ StyleBox["TT[p1_, p2_, p3_]", "Input"],
607
+ " represents the homogenous transformation matrix that, multiplied by a \
608
+ general point",
609
+ StyleBox[" {X,Y,Z,1}", "Input"],
610
+ ", gives the coordinates of the point in the local reference frame.\nFor \
611
+ efficiency in calculation, though we need to do some simplification:"
612
+ }], "Text",
613
+ CellChangeTimes->{{3.6805186306793423`*^9, 3.680518750910421*^9}, {
614
+ 3.6805187840986347`*^9, 3.680518819345417*^9}}],
615
+
616
+ Cell[CellGroupData[{
617
+
618
+ Cell[BoxData[{
619
+ RowBox[{
620
+ RowBox[{"rules", " ", "=",
621
+ RowBox[{"{", "\[IndentingNewLine]",
622
+ RowBox[{
623
+ RowBox[{
624
+ RowBox[{"p1x", "+", "p2x"}], "\[Rule]", "p1x2x"}], ",",
625
+ RowBox[{
626
+ RowBox[{"p1x", "-", "p2x"}], "\[Rule]", "p2x1x"}], ",",
627
+ RowBox[{
628
+ RowBox[{
629
+ RowBox[{"-", "p1x"}], "+", "p2x"}], "\[Rule]",
630
+ RowBox[{"-", "p2x1x"}]}], ",", "\[IndentingNewLine]",
631
+ RowBox[{
632
+ RowBox[{"p1y", "+", "p2y"}], "\[Rule]", "p1y2y"}], ",",
633
+ RowBox[{
634
+ RowBox[{"p1y", "-", "p2y"}], "\[Rule]", "p2y1y"}], ",",
635
+ RowBox[{
636
+ RowBox[{
637
+ RowBox[{"-", "p1y"}], "+", "p2y"}], "\[Rule]",
638
+ RowBox[{"-", "p2y1y"}]}], ",", "\[IndentingNewLine]",
639
+ RowBox[{
640
+ RowBox[{"p1z", "+", "p2z"}], "\[Rule]", "p1z2z"}], ",",
641
+ RowBox[{
642
+ RowBox[{"p1z", "-", "p2z"}], "\[Rule]", "p2z1z"}], ",",
643
+ RowBox[{
644
+ RowBox[{
645
+ RowBox[{"-", "p1z"}], "+", "p2z"}], "\[Rule]",
646
+ RowBox[{"-", "p2z1z"}]}], ",", "\[IndentingNewLine]",
647
+ RowBox[{
648
+ RowBox[{
649
+ SuperscriptBox["p2x1x", "2"], "+",
650
+ SuperscriptBox["p2y1y", "2"], "+",
651
+ SuperscriptBox["p2z1z", "2"]}], " ", "\[Rule]", " ", "p21"}], ",",
652
+ "\[IndentingNewLine]",
653
+ RowBox[{
654
+ RowBox[{"p1z", "-", "p3z"}], " ", "\[Rule]", " ", "p3z1z"}], ",", " ",
655
+ RowBox[{
656
+ RowBox[{
657
+ RowBox[{"-", "p1z"}], "+", "p3z"}], " ", "\[Rule]", " ",
658
+ RowBox[{"-", "p3z1z"}]}], ",", "\[IndentingNewLine]",
659
+ RowBox[{
660
+ RowBox[{"Sqrt", "[",
661
+ RowBox[{
662
+ SuperscriptBox["p1y", "2"], "+",
663
+ SuperscriptBox["p1z", "2"], "-",
664
+ RowBox[{"2", " ", "p1y", " ", "p2y"}], "+",
665
+ SuperscriptBox["p2y", "2"], "-",
666
+ RowBox[{"2", " ", "p1z", " ", "p2z"}], "+",
667
+ SuperscriptBox["p2z", "2"]}], "]"}], "\[Rule]", "psq"}]}],
668
+ "\[IndentingNewLine]", "}"}]}], ";"}], "\[IndentingNewLine]",
669
+ RowBox[{"TTs", "=",
670
+ RowBox[{
671
+ RowBox[{"Simplify", "[",
672
+ RowBox[{
673
+ RowBox[{"TT", "[",
674
+ RowBox[{
675
+ RowBox[{"{",
676
+ RowBox[{"p1x", ",", "p1y", ",", "p1z"}], "}"}], ",",
677
+ RowBox[{"{",
678
+ RowBox[{"p2x", ",", "p2y", ",", "p2z"}], "}"}], ",",
679
+ RowBox[{"{",
680
+ RowBox[{"p3x", ",", "p3y", ",", "p3z"}], "}"}]}], "]"}], ",", " ",
681
+ RowBox[{"Element", "[",
682
+ RowBox[{
683
+ RowBox[{"{",
684
+ RowBox[{
685
+ "p1x", ",", "p1y", ",", "p1z", ",", "p2x", ",", "p2y", ",", "p2z",
686
+ ",", "p3x", ",", "p3y", ",", "p3z"}], "}"}], ",", "Reals"}], "]"}]}],
687
+ "]"}], "//.", "rules"}]}]}], "Input",
688
+ CellChangeTimes->CompressedData["
689
+ 1:eJwdxU0ogwEABuA1+yk1q+26zGZjYmW11hSfVlYbY5GD2lZjVsbKSnZwUdtk
690
+ tZJpiakxUrv428Fp2drKsliW0lIitiQHGWLK+N4dnh7B2PSQlUqhUHgknJvV
691
+ lGn2FxWVJvjDjosAi06ue8vy8FKiWYgPuQNNePXnXIWdKa0aa11RLc7niF6s
692
+ yQX1mJtuHMGeh3ojZvV8WXHIcOvACmXai+20ih/fcC43qvPFYZw0XFV3m6R7
693
+ WN6RPMKxM10cO07MSTz56qczyCOlOyauFC1sTKuZ42Kzbl6AC99sIQ5kDRKc
694
+ c7a14u16IYGjfQw1dskto3h3/3oKOxcJL860M3xYpPctYyUhXsG2YdMaDtX+
695
+ ruPSweMWnpEu7OC6T2kEJzyCY2x84sewW2bL4PuiIosnNk/zOFiWNDDJOe/h
696
+ FtyZEsnwRyVRfbD/uQsXxuPd+B+TcMgI
697
+ "]],
698
+
699
+ Cell[BoxData[
700
+ RowBox[{"TransformationFunction", "[",
701
+ RowBox[{"(",
702
+ TagBox[GridBox[{
703
+ {
704
+ RowBox[{"-",
705
+ FractionBox["p2x1x",
706
+ SqrtBox["p21"]]}],
707
+ RowBox[{"-",
708
+ SqrtBox[
709
+ RowBox[{"1", "-",
710
+ FractionBox[
711
+ SuperscriptBox["p2x1x", "2"], "p21"]}]]}], "0",
712
+ FractionBox[
713
+ RowBox[{
714
+ SuperscriptBox["p1x", "2"], "-",
715
+ RowBox[{"p1x", " ", "p2x"}], "+",
716
+ RowBox[{"p1y", " ", "psq"}]}],
717
+ SqrtBox["p21"]]},
718
+ {
719
+ RowBox[{
720
+ RowBox[{"(",
721
+ RowBox[{
722
+ RowBox[{
723
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
724
+ RowBox[{"p2x", " ", "p3y"}], "+",
725
+ RowBox[{"p3x", " ", "psq"}], "-",
726
+ RowBox[{"p1x", " ",
727
+ RowBox[{"(",
728
+ RowBox[{
729
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}], ")"}],
730
+ "/",
731
+ RowBox[{"(",
732
+ RowBox[{"\[Sqrt]",
733
+ RowBox[{"(",
734
+ RowBox[{
735
+ RowBox[{"(",
736
+ RowBox[{
737
+ SuperscriptBox[
738
+ RowBox[{"(",
739
+ RowBox[{
740
+ SuperscriptBox["p1x", "2"], "+",
741
+ SuperscriptBox["p1y", "2"], "+",
742
+ SuperscriptBox["p1z", "2"], "-",
743
+ RowBox[{"2", " ", "p1x", " ", "p2x"}], "+",
744
+ SuperscriptBox["p2x", "2"], "-",
745
+ RowBox[{"2", " ", "p1y", " ", "p2y"}], "+",
746
+ SuperscriptBox["p2y", "2"], "-",
747
+ RowBox[{"2", " ", "p1z", " ", "p2z"}], "+",
748
+ SuperscriptBox["p2z", "2"]}], ")"}], "2"], " ",
749
+ RowBox[{"(",
750
+ RowBox[{
751
+ SuperscriptBox["p3z1z", "2"], "+",
752
+ SuperscriptBox[
753
+ RowBox[{"Abs", "[",
754
+ FractionBox[
755
+ RowBox[{
756
+ RowBox[{
757
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
758
+ RowBox[{"p2x", " ", "p3y"}], "+",
759
+ RowBox[{"p3x", " ", "psq"}], "-",
760
+ RowBox[{"p1x", " ",
761
+ RowBox[{"(",
762
+ RowBox[{
763
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
764
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}], ")"}], "/",
765
+ RowBox[{"(",
766
+ RowBox[{
767
+ SuperscriptBox["p1y", "2"], "+",
768
+ SuperscriptBox["p1z", "2"], "-",
769
+ RowBox[{"2", " ", "p1y", " ", "p2y"}], "+",
770
+ SuperscriptBox["p2y", "2"], "-",
771
+ RowBox[{"2", " ", "p1z", " ", "p2z"}], "+",
772
+ SuperscriptBox["p2z", "2"]}], ")"}]}], ")"}]}], ")"}]}],
773
+ FractionBox[
774
+ RowBox[{"p2x1x", " ",
775
+ RowBox[{"(",
776
+ RowBox[{
777
+ RowBox[{"p1y", " ", "p2x"}], "-",
778
+ RowBox[{"p2x", " ", "p3y"}], "-",
779
+ RowBox[{"p3x", " ", "psq"}], "+",
780
+ RowBox[{"p1x", " ",
781
+ RowBox[{"(",
782
+ RowBox[{
783
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
784
+ ")"}]}],
785
+ RowBox[{"p21", " ",
786
+ SqrtBox[
787
+ RowBox[{
788
+ SuperscriptBox["p3z1z", "2"], "+",
789
+ SuperscriptBox[
790
+ RowBox[{"Abs", "[",
791
+ FractionBox[
792
+ RowBox[{
793
+ RowBox[{
794
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
795
+ RowBox[{"p2x", " ", "p3y"}], "+",
796
+ RowBox[{"p3x", " ", "psq"}], "-",
797
+ RowBox[{"p1x", " ",
798
+ RowBox[{"(",
799
+ RowBox[{
800
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
801
+ SqrtBox["p21"]], "]"}], "2"]}]]}]],
802
+ SqrtBox[
803
+ RowBox[{"1", "-",
804
+ FractionBox[
805
+ SuperscriptBox[
806
+ RowBox[{"(",
807
+ RowBox[{
808
+ RowBox[{"p1y", " ", "p2x"}], "-",
809
+ RowBox[{"p2x", " ", "p3y"}], "-",
810
+ RowBox[{"p3x", " ", "psq"}], "+",
811
+ RowBox[{"p1x", " ",
812
+ RowBox[{"(",
813
+ RowBox[{
814
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
815
+ ")"}], "2"],
816
+ RowBox[{"p21", " ",
817
+ RowBox[{"(",
818
+ RowBox[{
819
+ SuperscriptBox["p3z1z", "2"], "+",
820
+ SuperscriptBox[
821
+ RowBox[{"Abs", "[",
822
+ FractionBox[
823
+ RowBox[{
824
+ RowBox[{
825
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
826
+ RowBox[{"p2x", " ", "p3y"}], "+",
827
+ RowBox[{"p3x", " ", "psq"}], "-",
828
+ RowBox[{"p1x", " ",
829
+ RowBox[{"(",
830
+ RowBox[{
831
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
832
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]],
833
+ RowBox[{
834
+ FractionBox[
835
+ RowBox[{
836
+ RowBox[{"(",
837
+ RowBox[{
838
+ RowBox[{"p1y", " ", "p2x"}], "+",
839
+ RowBox[{"p1x", " ",
840
+ RowBox[{"(",
841
+ RowBox[{
842
+ RowBox[{"-", "p1y"}], "+", "psq"}], ")"}]}]}], ")"}], " ",
843
+ RowBox[{"(",
844
+ RowBox[{
845
+ RowBox[{"p1y", " ", "p2x"}], "-",
846
+ RowBox[{"p2x", " ", "p3y"}], "-",
847
+ RowBox[{"p3x", " ", "psq"}], "+",
848
+ RowBox[{"p1x", " ",
849
+ RowBox[{"(",
850
+ RowBox[{
851
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
852
+ ")"}]}],
853
+ RowBox[{"p21", " ",
854
+ SqrtBox[
855
+ RowBox[{
856
+ SuperscriptBox["p3z1z", "2"], "+",
857
+ SuperscriptBox[
858
+ RowBox[{"Abs", "[",
859
+ FractionBox[
860
+ RowBox[{
861
+ RowBox[{
862
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
863
+ RowBox[{"p2x", " ", "p3y"}], "+",
864
+ RowBox[{"p3x", " ", "psq"}], "-",
865
+ RowBox[{"p1x", " ",
866
+ RowBox[{"(",
867
+ RowBox[{
868
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
869
+
870
+ SqrtBox["p21"]], "]"}], "2"]}]]}]], "-",
871
+ RowBox[{"p1z", " ",
872
+ SqrtBox[
873
+ RowBox[{"1", "-",
874
+ FractionBox[
875
+ SuperscriptBox[
876
+ RowBox[{"(",
877
+ RowBox[{
878
+ RowBox[{"p1y", " ", "p2x"}], "-",
879
+ RowBox[{"p2x", " ", "p3y"}], "-",
880
+ RowBox[{"p3x", " ", "psq"}], "+",
881
+ RowBox[{"p1x", " ",
882
+ RowBox[{"(",
883
+ RowBox[{
884
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
885
+ ")"}], "2"],
886
+ RowBox[{"p21", " ",
887
+ RowBox[{"(",
888
+ RowBox[{
889
+ SuperscriptBox["p3z1z", "2"], "+",
890
+ SuperscriptBox[
891
+ RowBox[{"Abs", "[",
892
+ FractionBox[
893
+ RowBox[{
894
+ RowBox[{
895
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
896
+ RowBox[{"p2x", " ", "p3y"}], "+",
897
+ RowBox[{"p3x", " ", "psq"}], "-",
898
+ RowBox[{"p1x", " ",
899
+ RowBox[{"(",
900
+ RowBox[{
901
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
902
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}]}]},
903
+ {
904
+ RowBox[{
905
+ RowBox[{"-",
906
+ SqrtBox[
907
+ RowBox[{"1", "-",
908
+ FractionBox[
909
+ SuperscriptBox["p2x1x", "2"], "p21"]}]]}], " ",
910
+ SqrtBox[
911
+ RowBox[{"1", "-",
912
+ FractionBox[
913
+ SuperscriptBox[
914
+ RowBox[{"(",
915
+ RowBox[{
916
+ RowBox[{"p1y", " ", "p2x"}], "-",
917
+ RowBox[{"p2x", " ", "p3y"}], "-",
918
+ RowBox[{"p3x", " ", "psq"}], "+",
919
+ RowBox[{"p1x", " ",
920
+ RowBox[{"(",
921
+ RowBox[{
922
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
923
+ ")"}], "2"],
924
+ RowBox[{"p21", " ",
925
+ RowBox[{"(",
926
+ RowBox[{
927
+ SuperscriptBox["p3z1z", "2"], "+",
928
+ SuperscriptBox[
929
+ RowBox[{"Abs", "[",
930
+ FractionBox[
931
+ RowBox[{
932
+ RowBox[{
933
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
934
+ RowBox[{"p2x", " ", "p3y"}], "+",
935
+ RowBox[{"p3x", " ", "psq"}], "-",
936
+ RowBox[{"p1x", " ",
937
+ RowBox[{"(",
938
+ RowBox[{
939
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
940
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}],
941
+ FractionBox[
942
+ RowBox[{"p2x1x", " ",
943
+ SqrtBox[
944
+ RowBox[{"1", "-",
945
+ FractionBox[
946
+ SuperscriptBox[
947
+ RowBox[{"(",
948
+ RowBox[{
949
+ RowBox[{"p1y", " ", "p2x"}], "-",
950
+ RowBox[{"p2x", " ", "p3y"}], "-",
951
+ RowBox[{"p3x", " ", "psq"}], "+",
952
+ RowBox[{"p1x", " ",
953
+ RowBox[{"(",
954
+ RowBox[{
955
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
956
+ ")"}], "2"],
957
+ RowBox[{"p21", " ",
958
+ RowBox[{"(",
959
+ RowBox[{
960
+ SuperscriptBox["p3z1z", "2"], "+",
961
+ SuperscriptBox[
962
+ RowBox[{"Abs", "[",
963
+ FractionBox[
964
+ RowBox[{
965
+ RowBox[{
966
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
967
+ RowBox[{"p2x", " ", "p3y"}], "+",
968
+ RowBox[{"p3x", " ", "psq"}], "-",
969
+ RowBox[{"p1x", " ",
970
+ RowBox[{"(",
971
+ RowBox[{
972
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
973
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}],
974
+ SqrtBox["p21"]],
975
+ FractionBox[
976
+ RowBox[{
977
+ RowBox[{
978
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
979
+ RowBox[{"p2x", " ", "p3y"}], "+",
980
+ RowBox[{"p3x", " ", "psq"}], "-",
981
+ RowBox[{"p1x", " ",
982
+ RowBox[{"(",
983
+ RowBox[{
984
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
985
+ SqrtBox[
986
+ RowBox[{"p21", " ",
987
+ RowBox[{"(",
988
+ RowBox[{
989
+ SuperscriptBox["p3z1z", "2"], "+",
990
+ SuperscriptBox[
991
+ RowBox[{"Abs", "[",
992
+ FractionBox[
993
+ RowBox[{
994
+ RowBox[{
995
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
996
+ RowBox[{"p2x", " ", "p3y"}], "+",
997
+ RowBox[{"p3x", " ", "psq"}], "-",
998
+ RowBox[{"p1x", " ",
999
+ RowBox[{"(",
1000
+ RowBox[{
1001
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1002
+
1003
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]],
1004
+ RowBox[{
1005
+ FractionBox[
1006
+ RowBox[{"p1z", " ",
1007
+ RowBox[{"(",
1008
+ RowBox[{
1009
+ RowBox[{"p1y", " ", "p2x"}], "-",
1010
+ RowBox[{"p2x", " ", "p3y"}], "-",
1011
+ RowBox[{"p3x", " ", "psq"}], "+",
1012
+ RowBox[{"p1x", " ",
1013
+ RowBox[{"(",
1014
+ RowBox[{
1015
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1016
+ ")"}]}],
1017
+ SqrtBox[
1018
+ RowBox[{"p21", " ",
1019
+ RowBox[{"(",
1020
+ RowBox[{
1021
+ SuperscriptBox["p3z1z", "2"], "+",
1022
+ SuperscriptBox[
1023
+ RowBox[{"Abs", "[",
1024
+ FractionBox[
1025
+ RowBox[{
1026
+ RowBox[{
1027
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1028
+ RowBox[{"p2x", " ", "p3y"}], "+",
1029
+ RowBox[{"p3x", " ", "psq"}], "-",
1030
+ RowBox[{"p1x", " ",
1031
+ RowBox[{"(",
1032
+ RowBox[{
1033
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1034
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]], "+",
1035
+ FractionBox[
1036
+ RowBox[{
1037
+ RowBox[{"(",
1038
+ RowBox[{
1039
+ RowBox[{"p1y", " ", "p2x"}], "+",
1040
+ RowBox[{"p1x", " ",
1041
+ RowBox[{"(",
1042
+ RowBox[{
1043
+ RowBox[{"-", "p1y"}], "+", "psq"}], ")"}]}]}], ")"}], " ",
1044
+ SqrtBox[
1045
+ RowBox[{"1", "-",
1046
+ FractionBox[
1047
+ SuperscriptBox[
1048
+ RowBox[{"(",
1049
+ RowBox[{
1050
+ RowBox[{"p1y", " ", "p2x"}], "-",
1051
+ RowBox[{"p2x", " ", "p3y"}], "-",
1052
+ RowBox[{"p3x", " ", "psq"}], "+",
1053
+ RowBox[{"p1x", " ",
1054
+ RowBox[{"(",
1055
+ RowBox[{
1056
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1057
+ ")"}], "2"],
1058
+ RowBox[{"p21", " ",
1059
+ RowBox[{"(",
1060
+ RowBox[{
1061
+ SuperscriptBox["p3z1z", "2"], "+",
1062
+ SuperscriptBox[
1063
+ RowBox[{"Abs", "[",
1064
+ FractionBox[
1065
+ RowBox[{
1066
+ RowBox[{
1067
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1068
+ RowBox[{"p2x", " ", "p3y"}], "+",
1069
+ RowBox[{"p3x", " ", "psq"}], "-",
1070
+ RowBox[{"p1x", " ",
1071
+ RowBox[{"(",
1072
+ RowBox[{
1073
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1074
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}],
1075
+ SqrtBox["p21"]]}]},
1076
+ {"0", "0", "0", "1"}
1077
+ },
1078
+ AutoDelete->False,
1079
+ GridBoxDividers->{
1080
+ "Columns" -> {{False}}, "ColumnsIndexed" -> {-2 -> True},
1081
+ "Rows" -> {{False}}, "RowsIndexed" -> {-2 -> True}},
1082
+ GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
1083
+ #& ], ")"}], "]"}]], "Output",
1084
+ CellChangeTimes->{3.68051643962358*^9, 3.680516503553872*^9,
1085
+ 3.680516612833427*^9}]
1086
+ }, Open ]]
1087
+ }, Open ]],
1088
+
1089
+ Cell[CellGroupData[{
1090
+
1091
+ Cell["C code generation", "Chapter",
1092
+ CellChangeTimes->{{3.680518850048316*^9, 3.680518855670826*^9}}],
1093
+
1094
+ Cell["\<\
1095
+ Let\[CloseCurlyQuote]s apply the TTs transformation to a generic {X,Y,Z} \
1096
+ point:\
1097
+ \>", "Text",
1098
+ CellChangeTimes->{{3.680518841922998*^9, 3.6805188851237803`*^9}}],
1099
+
1100
+ Cell[CellGroupData[{
1101
+
1102
+ Cell[BoxData[
1103
+ RowBox[{"coords", "=",
1104
+ RowBox[{"TTs", "[",
1105
+ RowBox[{"{",
1106
+ RowBox[{"X", ",", "Y", ",", "Z"}], "}"}], "]"}]}]], "Input",
1107
+ CellChangeTimes->{{3.680515913771165*^9, 3.680515969646092*^9}, {
1108
+ 3.6805160238427877`*^9, 3.680516044753804*^9}, {3.680516099227186*^9,
1109
+ 3.680516145532996*^9}, {3.680516626548015*^9, 3.6805166759592743`*^9}, {
1110
+ 3.680523337036319*^9, 3.6805234065256367`*^9}, {3.680523477304611*^9,
1111
+ 3.680523508453442*^9}}],
1112
+
1113
+ Cell[BoxData[
1114
+ RowBox[{"{",
1115
+ RowBox[{
1116
+ RowBox[{
1117
+ FractionBox[
1118
+ RowBox[{
1119
+ SuperscriptBox["p1x", "2"], "-",
1120
+ RowBox[{"p1x", " ", "p2x"}], "+",
1121
+ RowBox[{"p1y", " ", "psq"}]}],
1122
+ SqrtBox["p21"]], "-",
1123
+ FractionBox[
1124
+ RowBox[{"p2x1x", " ", "X"}],
1125
+ SqrtBox["p21"]], "-",
1126
+ RowBox[{
1127
+ SqrtBox[
1128
+ RowBox[{"1", "-",
1129
+ FractionBox[
1130
+ SuperscriptBox["p2x1x", "2"], "p21"]}]], " ", "Y"}]}], ",",
1131
+ RowBox[{
1132
+ FractionBox[
1133
+ RowBox[{
1134
+ RowBox[{"(",
1135
+ RowBox[{
1136
+ RowBox[{"p1y", " ", "p2x"}], "+",
1137
+ RowBox[{"p1x", " ",
1138
+ RowBox[{"(",
1139
+ RowBox[{
1140
+ RowBox[{"-", "p1y"}], "+", "psq"}], ")"}]}]}], ")"}], " ",
1141
+ RowBox[{"(",
1142
+ RowBox[{
1143
+ RowBox[{"p1y", " ", "p2x"}], "-",
1144
+ RowBox[{"p2x", " ", "p3y"}], "-",
1145
+ RowBox[{"p3x", " ", "psq"}], "+",
1146
+ RowBox[{"p1x", " ",
1147
+ RowBox[{"(",
1148
+ RowBox[{
1149
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}], ")"}]}],
1150
+ RowBox[{"p21", " ",
1151
+ SqrtBox[
1152
+ RowBox[{
1153
+ SuperscriptBox["p3z1z", "2"], "+",
1154
+ SuperscriptBox[
1155
+ RowBox[{"Abs", "[",
1156
+ FractionBox[
1157
+ RowBox[{
1158
+ RowBox[{
1159
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1160
+ RowBox[{"p2x", " ", "p3y"}], "+",
1161
+ RowBox[{"p3x", " ", "psq"}], "-",
1162
+ RowBox[{"p1x", " ",
1163
+ RowBox[{"(",
1164
+ RowBox[{
1165
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1166
+ SqrtBox["p21"]], "]"}], "2"]}]]}]], "+",
1167
+ FractionBox[
1168
+ RowBox[{"p2x1x", " ",
1169
+ RowBox[{"(",
1170
+ RowBox[{
1171
+ RowBox[{"p1y", " ", "p2x"}], "-",
1172
+ RowBox[{"p2x", " ", "p3y"}], "-",
1173
+ RowBox[{"p3x", " ", "psq"}], "+",
1174
+ RowBox[{"p1x", " ",
1175
+ RowBox[{"(",
1176
+ RowBox[{
1177
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}], ")"}],
1178
+ " ", "Y"}],
1179
+ RowBox[{"p21", " ",
1180
+ SqrtBox[
1181
+ RowBox[{
1182
+ SuperscriptBox["p3z1z", "2"], "+",
1183
+ SuperscriptBox[
1184
+ RowBox[{"Abs", "[",
1185
+ FractionBox[
1186
+ RowBox[{
1187
+ RowBox[{
1188
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1189
+ RowBox[{"p2x", " ", "p3y"}], "+",
1190
+ RowBox[{"p3x", " ", "psq"}], "-",
1191
+ RowBox[{"p1x", " ",
1192
+ RowBox[{"(",
1193
+ RowBox[{
1194
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1195
+ SqrtBox["p21"]], "]"}], "2"]}]]}]], "+",
1196
+ FractionBox[
1197
+ RowBox[{
1198
+ RowBox[{"(",
1199
+ RowBox[{
1200
+ RowBox[{
1201
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1202
+ RowBox[{"p2x", " ", "p3y"}], "+",
1203
+ RowBox[{"p3x", " ", "psq"}], "-",
1204
+ RowBox[{"p1x", " ",
1205
+ RowBox[{"(",
1206
+ RowBox[{
1207
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}], ")"}],
1208
+ " ", "X"}],
1209
+ SqrtBox[
1210
+ FractionBox[
1211
+ RowBox[{
1212
+ SuperscriptBox[
1213
+ RowBox[{"(",
1214
+ RowBox[{
1215
+ SuperscriptBox["p1x", "2"], "+",
1216
+ SuperscriptBox["p1y", "2"], "+",
1217
+ SuperscriptBox["p1z", "2"], "-",
1218
+ RowBox[{"2", " ", "p1x", " ", "p2x"}], "+",
1219
+ SuperscriptBox["p2x", "2"], "-",
1220
+ RowBox[{"2", " ", "p1y", " ", "p2y"}], "+",
1221
+ SuperscriptBox["p2y", "2"], "-",
1222
+ RowBox[{"2", " ", "p1z", " ", "p2z"}], "+",
1223
+ SuperscriptBox["p2z", "2"]}], ")"}], "2"], " ",
1224
+ RowBox[{"(",
1225
+ RowBox[{
1226
+ SuperscriptBox["p3z1z", "2"], "+",
1227
+ SuperscriptBox[
1228
+ RowBox[{"Abs", "[",
1229
+ FractionBox[
1230
+ RowBox[{
1231
+ RowBox[{
1232
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1233
+ RowBox[{"p2x", " ", "p3y"}], "+",
1234
+ RowBox[{"p3x", " ", "psq"}], "-",
1235
+ RowBox[{"p1x", " ",
1236
+ RowBox[{"(",
1237
+ RowBox[{
1238
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1239
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}],
1240
+ RowBox[{
1241
+ SuperscriptBox["p1y", "2"], "+",
1242
+ SuperscriptBox["p1z", "2"], "-",
1243
+ RowBox[{"2", " ", "p1y", " ", "p2y"}], "+",
1244
+ SuperscriptBox["p2y", "2"], "-",
1245
+ RowBox[{"2", " ", "p1z", " ", "p2z"}], "+",
1246
+ SuperscriptBox["p2z", "2"]}]]]], "-",
1247
+ RowBox[{"p1z", " ",
1248
+ SqrtBox[
1249
+ RowBox[{"1", "-",
1250
+ FractionBox[
1251
+ SuperscriptBox[
1252
+ RowBox[{"(",
1253
+ RowBox[{
1254
+ RowBox[{"p1y", " ", "p2x"}], "-",
1255
+ RowBox[{"p2x", " ", "p3y"}], "-",
1256
+ RowBox[{"p3x", " ", "psq"}], "+",
1257
+ RowBox[{"p1x", " ",
1258
+ RowBox[{"(",
1259
+ RowBox[{
1260
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1261
+ ")"}], "2"],
1262
+ RowBox[{"p21", " ",
1263
+ RowBox[{"(",
1264
+ RowBox[{
1265
+ SuperscriptBox["p3z1z", "2"], "+",
1266
+ SuperscriptBox[
1267
+ RowBox[{"Abs", "[",
1268
+ FractionBox[
1269
+ RowBox[{
1270
+ RowBox[{
1271
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1272
+ RowBox[{"p2x", " ", "p3y"}], "+",
1273
+ RowBox[{"p3x", " ", "psq"}], "-",
1274
+ RowBox[{"p1x", " ",
1275
+ RowBox[{"(",
1276
+ RowBox[{
1277
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1278
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}], "+",
1279
+ RowBox[{"Z", " ",
1280
+ SqrtBox[
1281
+ RowBox[{"1", "-",
1282
+ FractionBox[
1283
+ SuperscriptBox[
1284
+ RowBox[{"(",
1285
+ RowBox[{
1286
+ RowBox[{"p1y", " ", "p2x"}], "-",
1287
+ RowBox[{"p2x", " ", "p3y"}], "-",
1288
+ RowBox[{"p3x", " ", "psq"}], "+",
1289
+ RowBox[{"p1x", " ",
1290
+ RowBox[{"(",
1291
+ RowBox[{
1292
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1293
+ ")"}], "2"],
1294
+ RowBox[{"p21", " ",
1295
+ RowBox[{"(",
1296
+ RowBox[{
1297
+ SuperscriptBox["p3z1z", "2"], "+",
1298
+ SuperscriptBox[
1299
+ RowBox[{"Abs", "[",
1300
+ FractionBox[
1301
+ RowBox[{
1302
+ RowBox[{
1303
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1304
+ RowBox[{"p2x", " ", "p3y"}], "+",
1305
+ RowBox[{"p3x", " ", "psq"}], "-",
1306
+ RowBox[{"p1x", " ",
1307
+ RowBox[{"(",
1308
+ RowBox[{
1309
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1310
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}]}], ",",
1311
+ RowBox[{
1312
+ FractionBox[
1313
+ RowBox[{"p1z", " ",
1314
+ RowBox[{"(",
1315
+ RowBox[{
1316
+ RowBox[{"p1y", " ", "p2x"}], "-",
1317
+ RowBox[{"p2x", " ", "p3y"}], "-",
1318
+ RowBox[{"p3x", " ", "psq"}], "+",
1319
+ RowBox[{"p1x", " ",
1320
+ RowBox[{"(",
1321
+ RowBox[{
1322
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}], ")"}]}],
1323
+ SqrtBox[
1324
+ RowBox[{"p21", " ",
1325
+ RowBox[{"(",
1326
+ RowBox[{
1327
+ SuperscriptBox["p3z1z", "2"], "+",
1328
+ SuperscriptBox[
1329
+ RowBox[{"Abs", "[",
1330
+ FractionBox[
1331
+ RowBox[{
1332
+ RowBox[{
1333
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1334
+ RowBox[{"p2x", " ", "p3y"}], "+",
1335
+ RowBox[{"p3x", " ", "psq"}], "-",
1336
+ RowBox[{"p1x", " ",
1337
+ RowBox[{"(",
1338
+ RowBox[{
1339
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1340
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]], "+",
1341
+ FractionBox[
1342
+ RowBox[{
1343
+ RowBox[{"(",
1344
+ RowBox[{
1345
+ RowBox[{
1346
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1347
+ RowBox[{"p2x", " ", "p3y"}], "+",
1348
+ RowBox[{"p3x", " ", "psq"}], "-",
1349
+ RowBox[{"p1x", " ",
1350
+ RowBox[{"(",
1351
+ RowBox[{
1352
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}], ")"}],
1353
+ " ", "Z"}],
1354
+ SqrtBox[
1355
+ RowBox[{"p21", " ",
1356
+ RowBox[{"(",
1357
+ RowBox[{
1358
+ SuperscriptBox["p3z1z", "2"], "+",
1359
+ SuperscriptBox[
1360
+ RowBox[{"Abs", "[",
1361
+ FractionBox[
1362
+ RowBox[{
1363
+ RowBox[{
1364
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1365
+ RowBox[{"p2x", " ", "p3y"}], "+",
1366
+ RowBox[{"p3x", " ", "psq"}], "-",
1367
+ RowBox[{"p1x", " ",
1368
+ RowBox[{"(",
1369
+ RowBox[{
1370
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1371
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]], "+",
1372
+ FractionBox[
1373
+ RowBox[{
1374
+ RowBox[{"(",
1375
+ RowBox[{
1376
+ RowBox[{"p1y", " ", "p2x"}], "+",
1377
+ RowBox[{"p1x", " ",
1378
+ RowBox[{"(",
1379
+ RowBox[{
1380
+ RowBox[{"-", "p1y"}], "+", "psq"}], ")"}]}]}], ")"}], " ",
1381
+ SqrtBox[
1382
+ RowBox[{"1", "-",
1383
+ FractionBox[
1384
+ SuperscriptBox[
1385
+ RowBox[{"(",
1386
+ RowBox[{
1387
+ RowBox[{"p1y", " ", "p2x"}], "-",
1388
+ RowBox[{"p2x", " ", "p3y"}], "-",
1389
+ RowBox[{"p3x", " ", "psq"}], "+",
1390
+ RowBox[{"p1x", " ",
1391
+ RowBox[{"(",
1392
+ RowBox[{
1393
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1394
+ ")"}], "2"],
1395
+ RowBox[{"p21", " ",
1396
+ RowBox[{"(",
1397
+ RowBox[{
1398
+ SuperscriptBox["p3z1z", "2"], "+",
1399
+ SuperscriptBox[
1400
+ RowBox[{"Abs", "[",
1401
+ FractionBox[
1402
+ RowBox[{
1403
+ RowBox[{
1404
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1405
+ RowBox[{"p2x", " ", "p3y"}], "+",
1406
+ RowBox[{"p3x", " ", "psq"}], "-",
1407
+ RowBox[{"p1x", " ",
1408
+ RowBox[{"(",
1409
+ RowBox[{
1410
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1411
+
1412
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}],
1413
+ SqrtBox["p21"]], "-",
1414
+ RowBox[{
1415
+ SqrtBox[
1416
+ RowBox[{"1", "-",
1417
+ FractionBox[
1418
+ SuperscriptBox["p2x1x", "2"], "p21"]}]], " ", "X", " ",
1419
+ SqrtBox[
1420
+ RowBox[{"1", "-",
1421
+ FractionBox[
1422
+ SuperscriptBox[
1423
+ RowBox[{"(",
1424
+ RowBox[{
1425
+ RowBox[{"p1y", " ", "p2x"}], "-",
1426
+ RowBox[{"p2x", " ", "p3y"}], "-",
1427
+ RowBox[{"p3x", " ", "psq"}], "+",
1428
+ RowBox[{"p1x", " ",
1429
+ RowBox[{"(",
1430
+ RowBox[{
1431
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1432
+ ")"}], "2"],
1433
+ RowBox[{"p21", " ",
1434
+ RowBox[{"(",
1435
+ RowBox[{
1436
+ SuperscriptBox["p3z1z", "2"], "+",
1437
+ SuperscriptBox[
1438
+ RowBox[{"Abs", "[",
1439
+ FractionBox[
1440
+ RowBox[{
1441
+ RowBox[{
1442
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1443
+ RowBox[{"p2x", " ", "p3y"}], "+",
1444
+ RowBox[{"p3x", " ", "psq"}], "-",
1445
+ RowBox[{"p1x", " ",
1446
+ RowBox[{"(",
1447
+ RowBox[{
1448
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1449
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}], "+",
1450
+ FractionBox[
1451
+ RowBox[{"p2x1x", " ", "Y", " ",
1452
+ SqrtBox[
1453
+ RowBox[{"1", "-",
1454
+ FractionBox[
1455
+ SuperscriptBox[
1456
+ RowBox[{"(",
1457
+ RowBox[{
1458
+ RowBox[{"p1y", " ", "p2x"}], "-",
1459
+ RowBox[{"p2x", " ", "p3y"}], "-",
1460
+ RowBox[{"p3x", " ", "psq"}], "+",
1461
+ RowBox[{"p1x", " ",
1462
+ RowBox[{"(",
1463
+ RowBox[{
1464
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1465
+ ")"}], "2"],
1466
+ RowBox[{"p21", " ",
1467
+ RowBox[{"(",
1468
+ RowBox[{
1469
+ SuperscriptBox["p3z1z", "2"], "+",
1470
+ SuperscriptBox[
1471
+ RowBox[{"Abs", "[",
1472
+ FractionBox[
1473
+ RowBox[{
1474
+ RowBox[{
1475
+ RowBox[{"-", "p1y"}], " ", "p2x"}], "+",
1476
+ RowBox[{"p2x", " ", "p3y"}], "+",
1477
+ RowBox[{"p3x", " ", "psq"}], "-",
1478
+ RowBox[{"p1x", " ",
1479
+ RowBox[{"(",
1480
+ RowBox[{
1481
+ RowBox[{"-", "p1y"}], "+", "p3y", "+", "psq"}], ")"}]}]}],
1482
+
1483
+ SqrtBox["p21"]], "]"}], "2"]}], ")"}]}]]}]]}],
1484
+ SqrtBox["p21"]]}]}], "}"}]], "Output",
1485
+ CellChangeTimes->{{3.680515931159046*^9, 3.680515970319158*^9}, {
1486
+ 3.680516033813797*^9, 3.680516045987493*^9}, 3.680516146457004*^9, {
1487
+ 3.6805166409316807`*^9, 3.680516676692367*^9}, {3.680523340399345*^9,
1488
+ 3.680523374595524*^9}, 3.6805234085744257`*^9, 3.68052347844438*^9,
1489
+ 3.680523510066864*^9, 3.680523988459366*^9}]
1490
+ }, Open ]],
1491
+
1492
+ Cell["Now, let\[CloseCurlyQuote]s generate the C code for the three \
1493
+ coordinates:", "Text",
1494
+ CellChangeTimes->{{3.6805188954077177`*^9, 3.680518912810919*^9}}],
1495
+
1496
+ Cell[CellGroupData[{
1497
+
1498
+ Cell[BoxData[{
1499
+ RowBox[{
1500
+ RowBox[{"\"\<Xt = \>\"", "<>", " ",
1501
+ RowBox[{"ToString", "[",
1502
+ RowBox[{
1503
+ RowBox[{
1504
+ RowBox[{"TTs", "[",
1505
+ RowBox[{"{",
1506
+ RowBox[{"X", ",", "Y", ",", "Z"}], "}"}], "]"}],
1507
+ "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], ",", " ",
1508
+ "CForm"}], "]"}], "<>", "\"\<;\\n\>\""}], ";"}], "\[IndentingNewLine]",
1509
+ RowBox[{" ",
1510
+ RowBox[{
1511
+ RowBox[{"%", "<>", "\"\<Yt = \>\"", "<>",
1512
+ RowBox[{"ToString", "[",
1513
+ RowBox[{
1514
+ RowBox[{
1515
+ RowBox[{"TTs", "[",
1516
+ RowBox[{"{",
1517
+ RowBox[{"X", ",", "Y", ",", "Z"}], "}"}], "]"}],
1518
+ "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], ",", " ",
1519
+ "CForm"}], "]"}], "<>", "\"\<;\\n\>\""}],
1520
+ ";"}]}], "\[IndentingNewLine]",
1521
+ RowBox[{" ",
1522
+ RowBox[{"%", "<>", "\"\<Zt = \>\"", "<>",
1523
+ RowBox[{"ToString", "[",
1524
+ RowBox[{
1525
+ RowBox[{
1526
+ RowBox[{"TTs", "[",
1527
+ RowBox[{"{",
1528
+ RowBox[{"X", ",", "Y", ",", "Z"}], "}"}], "]"}],
1529
+ "\[LeftDoubleBracket]", "3", "\[RightDoubleBracket]"}], ",", " ",
1530
+ "CForm"}], "]"}], "<>", "\"\<;\\n\>\""}]}]}], "Input",
1531
+ CellChangeTimes->{{3.680516732709072*^9, 3.68051673506392*^9}, {
1532
+ 3.680516766935437*^9, 3.6805168219215117`*^9}, {3.680516906508892*^9,
1533
+ 3.6805169152265873`*^9}, {3.6805242979738092`*^9, 3.680524440761509*^9}, {
1534
+ 3.680525305800926*^9, 3.680525307848487*^9}, {3.680525455315522*^9,
1535
+ 3.6805254607165737`*^9}}],
1536
+
1537
+ Cell[BoxData["\<\"Xt = (Power(p1x,2) - p1x*p2x + p1y*psq)/Sqrt(p21) - \
1538
+ (p2x1x*X)/Sqrt(p21) - Sqrt(1 - Power(p2x1x,2)/p21)*Y;\\nYt = ((p1y*p2x + \
1539
+ p1x*(-p1y + psq))*(p1y*p2x - p2x*p3y - p3x*psq + p1x*(-p1y + p3y + \
1540
+ psq)))/(p21*Sqrt(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) + p2x*p3y + p3x*psq - \
1541
+ p1x*(-p1y + p3y + psq))/Sqrt(p21)),2))) + (p2x1x*(p1y*p2x - p2x*p3y - p3x*psq \
1542
+ + p1x*(-p1y + p3y + psq))*Y)/(p21*Sqrt(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) \
1543
+ + p2x*p3y + p3x*psq - p1x*(-p1y + p3y + psq))/Sqrt(p21)),2))) + ((-(p1y*p2x) \
1544
+ + p2x*p3y + p3x*psq - p1x*(-p1y + p3y + psq))*X)/Sqrt((Power(Power(p1x,2) + \
1545
+ Power(p1y,2) + Power(p1z,2) - 2*p1x*p2x + Power(p2x,2) - 2*p1y*p2y + \
1546
+ Power(p2y,2) - 2*p1z*p2z + Power(p2z,2),2)*(Power(p3z1z,2) + \
1547
+ Power(Abs((-(p1y*p2x) + p2x*p3y + p3x*psq - p1x*(-p1y + p3y + \
1548
+ psq))/Sqrt(p21)),2)))/(Power(p1y,2) + Power(p1z,2) - 2*p1y*p2y + Power(p2y,2) \
1549
+ - 2*p1z*p2z + Power(p2z,2))) - p1z*Sqrt(1 - Power(p1y*p2x - p2x*p3y - p3x*psq \
1550
+ + p1x*(-p1y + p3y + psq),2)/(p21*(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) + \
1551
+ p2x*p3y + p3x*psq - p1x*(-p1y + p3y + psq))/Sqrt(p21)),2)))) + Z*Sqrt(1 - \
1552
+ Power(p1y*p2x - p2x*p3y - p3x*psq + p1x*(-p1y + p3y + \
1553
+ psq),2)/(p21*(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) + p2x*p3y + p3x*psq - \
1554
+ p1x*(-p1y + p3y + psq))/Sqrt(p21)),2))));\\nZt = (p1z*(p1y*p2x - p2x*p3y - \
1555
+ p3x*psq + p1x*(-p1y + p3y + psq)))/Sqrt(p21*(Power(p3z1z,2) + \
1556
+ Power(Abs((-(p1y*p2x) + p2x*p3y + p3x*psq - p1x*(-p1y + p3y + \
1557
+ psq))/Sqrt(p21)),2))) + ((-(p1y*p2x) + p2x*p3y + p3x*psq - p1x*(-p1y + p3y + \
1558
+ psq))*Z)/Sqrt(p21*(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) + p2x*p3y + p3x*psq \
1559
+ - p1x*(-p1y + p3y + psq))/Sqrt(p21)),2))) + ((p1y*p2x + p1x*(-p1y + \
1560
+ psq))*Sqrt(1 - Power(p1y*p2x - p2x*p3y - p3x*psq + p1x*(-p1y + p3y + \
1561
+ psq),2)/(p21*(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) + p2x*p3y + p3x*psq - \
1562
+ p1x*(-p1y + p3y + psq))/Sqrt(p21)),2)))))/Sqrt(p21) - Sqrt(1 - \
1563
+ Power(p2x1x,2)/p21)*X*Sqrt(1 - Power(p1y*p2x - p2x*p3y - p3x*psq + p1x*(-p1y \
1564
+ + p3y + psq),2)/(p21*(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) + p2x*p3y + \
1565
+ p3x*psq - p1x*(-p1y + p3y + psq))/Sqrt(p21)),2)))) + (p2x1x*Y*Sqrt(1 - \
1566
+ Power(p1y*p2x - p2x*p3y - p3x*psq + p1x*(-p1y + p3y + \
1567
+ psq),2)/(p21*(Power(p3z1z,2) + Power(Abs((-(p1y*p2x) + p2x*p3y + p3x*psq - \
1568
+ p1x*(-p1y + p3y + psq))/Sqrt(p21)),2)))))/Sqrt(p21);\\n\"\>"], "Output",
1569
+ CellChangeTimes->{
1570
+ 3.6805168418942947`*^9, {3.680516908982044*^9, 3.6805169160619917`*^9}, {
1571
+ 3.6805243246760178`*^9, 3.680524373395739*^9}, {3.68052441476621*^9,
1572
+ 3.6805244433694468`*^9}, 3.680525309098633*^9, 3.680525471543971*^9}]
1573
+ }, Open ]],
1574
+
1575
+ Cell["\<\
1576
+ The only thing that\[CloseCurlyQuote]s missing now is the code representing \
1577
+ the set of rules used for simplifying the expression:\
1578
+ \>", "Text",
1579
+ CellChangeTimes->{{3.6805189232168713`*^9, 3.680518954155384*^9}}],
1580
+
1581
+ Cell[CellGroupData[{
1582
+
1583
+ Cell[BoxData[{
1584
+ RowBox[{
1585
+ RowBox[{"rules", "/.", " ",
1586
+ RowBox[{
1587
+ RowBox[{"HoldPattern", "[",
1588
+ RowBox[{"a_", "\[Rule]", "b_"}], "]"}], " ", "\[Rule]",
1589
+ RowBox[{"{",
1590
+ RowBox[{
1591
+ RowBox[{"{", "b", "}"}], ",",
1592
+ RowBox[{"{", "a", "}"}]}], "}"}]}]}], ";"}], "\[IndentingNewLine]",
1593
+ RowBox[{"rparts", "=",
1594
+ RowBox[{"Apply", "[",
1595
+ RowBox[{
1596
+ RowBox[{
1597
+ RowBox[{"ToString", "[",
1598
+ RowBox[{"#", ",", "CForm"}], "]"}], "&"}], ",", " ", "%", ",", " ",
1599
+ RowBox[{"{", "2", "}"}]}], "]"}]}]}], "Input",
1600
+ CellChangeTimes->{{3.6805171810760736`*^9, 3.680517196908794*^9}, {
1601
+ 3.680517229658133*^9, 3.680517242010722*^9}, {3.680517442063219*^9,
1602
+ 3.680517453458228*^9}, {3.680517483463866*^9, 3.680517517190979*^9}, {
1603
+ 3.680517575402288*^9, 3.680517588146268*^9}, {3.680519170410839*^9,
1604
+ 3.680519334121273*^9}, {3.680519371472104*^9, 3.6805193840717297`*^9}, {
1605
+ 3.6805194269707327`*^9, 3.680519429196887*^9}, {3.6805194703067293`*^9,
1606
+ 3.68051947113752*^9}, {3.680519609729042*^9, 3.680519610662447*^9}, {
1607
+ 3.680519643840981*^9, 3.6805196544152946`*^9}, {3.680519732729156*^9,
1608
+ 3.6805197677264977`*^9}, {3.680519801062408*^9, 3.680519805583221*^9}, {
1609
+ 3.680519874953183*^9, 3.680519890218712*^9}, {3.680519944332975*^9,
1610
+ 3.680520015073371*^9}, {3.6805200459812098`*^9, 3.6805200824171963`*^9}, {
1611
+ 3.6805201124225903`*^9, 3.6805201178216953`*^9}, {3.6805202987255898`*^9,
1612
+ 3.68052030253971*^9}, {3.680520609131083*^9, 3.680520657797782*^9}, {
1613
+ 3.680520763742194*^9, 3.680520764191395*^9}, 3.6805209359936733`*^9, {
1614
+ 3.6805210052385798`*^9, 3.680521006194029*^9}, {3.68052108661147*^9,
1615
+ 3.680521087589737*^9}, {3.6805226655003347`*^9, 3.680522682881522*^9}, {
1616
+ 3.6805252463547792`*^9, 3.6805252484109697`*^9}, 3.680525462706873*^9}],
1617
+
1618
+ Cell[BoxData[
1619
+ RowBox[{"{",
1620
+ RowBox[{
1621
+ RowBox[{"{",
1622
+ RowBox[{"\<\"p1x2x\"\>", ",", "\<\"p1x + p2x\"\>"}], "}"}], ",",
1623
+ RowBox[{"{",
1624
+ RowBox[{"\<\"p2x1x\"\>", ",", "\<\"p1x - p2x\"\>"}], "}"}], ",",
1625
+ RowBox[{"{",
1626
+ RowBox[{"\<\"-p2x1x\"\>", ",", "\<\"-p1x + p2x\"\>"}], "}"}], ",",
1627
+ RowBox[{"{",
1628
+ RowBox[{"\<\"p1y2y\"\>", ",", "\<\"p1y + p2y\"\>"}], "}"}], ",",
1629
+ RowBox[{"{",
1630
+ RowBox[{"\<\"p2y1y\"\>", ",", "\<\"p1y - p2y\"\>"}], "}"}], ",",
1631
+ RowBox[{"{",
1632
+ RowBox[{"\<\"-p2y1y\"\>", ",", "\<\"-p1y + p2y\"\>"}], "}"}], ",",
1633
+ RowBox[{"{",
1634
+ RowBox[{"\<\"p1z2z\"\>", ",", "\<\"p1z + p2z\"\>"}], "}"}], ",",
1635
+ RowBox[{"{",
1636
+ RowBox[{"\<\"p2z1z\"\>", ",", "\<\"p1z - p2z\"\>"}], "}"}], ",",
1637
+ RowBox[{"{",
1638
+ RowBox[{"\<\"-p2z1z\"\>", ",", "\<\"-p1z + p2z\"\>"}], "}"}], ",",
1639
+ RowBox[{"{",
1640
+ RowBox[{"\<\"p21\"\>",
1641
+ ",", "\<\"Power(p2x1x,2) + Power(p2y1y,2) + Power(p2z1z,2)\"\>"}], "}"}],
1642
+ ",",
1643
+ RowBox[{"{",
1644
+ RowBox[{"\<\"p3z1z\"\>", ",", "\<\"p1z - p3z\"\>"}], "}"}], ",",
1645
+ RowBox[{"{",
1646
+ RowBox[{"\<\"-p3z1z\"\>", ",", "\<\"-p1z + p3z\"\>"}], "}"}], ",",
1647
+ RowBox[{"{",
1648
+ RowBox[{"\<\"psq\"\>",
1649
+ ",", "\<\"Sqrt(Power(p1y,2) + Power(p1z,2) - 2*p1y*p2y + Power(p2y,2) - \
1650
+ 2*p1z*p2z + Power(p2z,2))\"\>"}], "}"}]}], "}"}]], "Output",
1651
+ CellChangeTimes->{
1652
+ 3.6805209363086853`*^9, 3.680521006984078*^9, 3.680521088066505*^9, {
1653
+ 3.68052267527857*^9, 3.680522685096283*^9}, 3.680524493491878*^9, {
1654
+ 3.680525250991354*^9, 3.680525277259371*^9}, 3.680525465510359*^9}]
1655
+ }, Open ]],
1656
+
1657
+ Cell[CellGroupData[{
1658
+
1659
+ Cell[BoxData[{
1660
+ RowBox[{
1661
+ RowBox[{"Apply", "[",
1662
+ RowBox[{
1663
+ RowBox[{
1664
+ RowBox[{
1665
+ RowBox[{"StringTemplate", "[", "\"\<`` = ``;\>\"", "]"}], "[",
1666
+ RowBox[{"#1", ",", "#2"}], "]"}], "&"}], ",", "rparts", ",",
1667
+ RowBox[{"{", "1", "}"}]}], "]"}], ";"}], "\[IndentingNewLine]",
1668
+ RowBox[{"Row", "[",
1669
+ RowBox[{"%", ",", "\"\<\\n\>\""}], "]"}]}], "Input",
1670
+ CellChangeTimes->{{3.6805223309553843`*^9, 3.680522457629376*^9}, {
1671
+ 3.680522628621615*^9, 3.680522633288886*^9}, {3.680524488697391*^9,
1672
+ 3.68052448976437*^9}, {3.680525284829358*^9, 3.680525285187552*^9}}],
1673
+
1674
+ Cell[BoxData[
1675
+ TemplateBox[{
1676
+ "\n","\"\\n\"","\"p1x2x = p1x + p2x;\"","\"p2x1x = p1x - p2x;\"",
1677
+ "\"-p2x1x = -p1x + p2x;\"","\"p1y2y = p1y + p2y;\"",
1678
+ "\"p2y1y = p1y - p2y;\"","\"-p2y1y = -p1y + p2y;\"",
1679
+ "\"p1z2z = p1z + p2z;\"","\"p2z1z = p1z - p2z;\"",
1680
+ "\"-p2z1z = -p1z + p2z;\"",
1681
+ "\"p21 = Power(p2x1x,2) + Power(p2y1y,2) + Power(p2z1z,2);\"",
1682
+ "\"p3z1z = p1z - p3z;\"","\"-p3z1z = -p1z + p3z;\"",
1683
+ "\"psq = Sqrt(Power(p1y,2) + Power(p1z,2) - 2*p1y*p2y + Power(p2y,2) - \
1684
+ 2*p1z*p2z + Power(p2z,2));\""},
1685
+ "RowWithSeparators"]], "Output",
1686
+ CellChangeTimes->{{3.68052242310878*^9, 3.680522460292264*^9}, {
1687
+ 3.680522629843586*^9, 3.6805226338945007`*^9}, 3.680522694633131*^9,
1688
+ 3.6805244951257153`*^9, {3.680525263928933*^9, 3.680525287379468*^9},
1689
+ 3.680525469016217*^9}]
1690
+ }, Open ]],
1691
+
1692
+ Cell[TextData[StyleBox["Just pay attention to remove the inverse rules!",
1693
+ FontWeight->"Bold"]], "Text",
1694
+ CellChangeTimes->{{3.680524590812296*^9, 3.680524602466028*^9}}]
1695
+ }, Open ]]
1696
+ }, Open ]]
1697
+ },
1698
+ WindowToolbars->"EditBar",
1699
+ WindowSize->{1967, 1331},
1700
+ WindowMargins->{{77, Automatic}, {Automatic, 0}},
1701
+ FrontEndVersion->"11.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (July 28, \
1702
+ 2016)",
1703
+ StyleDefinitions->"Default.nb"
1704
+ ]
1705
+ (* End of Notebook Content *)
1706
+
1707
+ (* Internal cache information *)
1708
+ (*CellTagsOutline
1709
+ CellTagsIndex->{}
1710
+ *)
1711
+ (*CellTagsIndex
1712
+ CellTagsIndex->{}
1713
+ *)
1714
+ (*NotebookFileOutline
1715
+ Notebook[{
1716
+ Cell[CellGroupData[{
1717
+ Cell[580, 22, 109, 1, 92, "Title"],
1718
+ Cell[692, 25, 723, 11, 68, "Text"],
1719
+ Cell[CellGroupData[{
1720
+ Cell[1440, 40, 96, 1, 65, "Chapter"],
1721
+ Cell[1539, 43, 1608, 38, 96, "Input"],
1722
+ Cell[3150, 83, 547, 14, 32, "Input"],
1723
+ Cell[CellGroupData[{
1724
+ Cell[3722, 101, 1064, 22, 32, "Input"],
1725
+ Cell[4789, 125, 1403, 27, 345, "Output"]
1726
+ }, Open ]],
1727
+ Cell[6207, 155, 562, 10, 106, "Text"],
1728
+ Cell[CellGroupData[{
1729
+ Cell[6794, 169, 4536, 118, 369, "Input"],
1730
+ Cell[11333, 289, 2061, 43, 631, "Output"],
1731
+ Cell[13397, 334, 950, 21, 35, "Output"],
1732
+ Cell[14350, 357, 1325, 30, 92, "Output"]
1733
+ }, Open ]]
1734
+ }, Open ]],
1735
+ Cell[CellGroupData[{
1736
+ Cell[15724, 393, 98, 1, 65, "Chapter"],
1737
+ Cell[15825, 396, 156, 3, 30, "Text"],
1738
+ Cell[15984, 401, 2615, 76, 159, "Input"],
1739
+ Cell[18602, 479, 140, 1, 30, "Text"],
1740
+ Cell[CellGroupData[{
1741
+ Cell[18767, 484, 2956, 76, 222, "Input"],
1742
+ Cell[21726, 562, 1797, 38, 313, "Output"]
1743
+ }, Open ]],
1744
+ Cell[23538, 603, 490, 10, 50, "Text"],
1745
+ Cell[CellGroupData[{
1746
+ Cell[24053, 617, 3057, 79, 207, "Input"],
1747
+ Cell[27113, 698, 14200, 386, 373, "Output"]
1748
+ }, Open ]]
1749
+ }, Open ]],
1750
+ Cell[CellGroupData[{
1751
+ Cell[41362, 1090, 102, 1, 65, "Chapter"],
1752
+ Cell[41467, 1093, 173, 4, 30, "Text"],
1753
+ Cell[CellGroupData[{
1754
+ Cell[41665, 1101, 457, 9, 32, "Input"],
1755
+ Cell[42125, 1112, 12830, 376, 452, "Output"]
1756
+ }, Open ]],
1757
+ Cell[54970, 1491, 160, 2, 30, "Text"],
1758
+ Cell[CellGroupData[{
1759
+ Cell[55155, 1497, 1445, 37, 75, "Input"],
1760
+ Cell[56603, 1536, 2578, 35, 285, "Output"]
1761
+ }, Open ]],
1762
+ Cell[59196, 1574, 223, 4, 30, "Text"],
1763
+ Cell[CellGroupData[{
1764
+ Cell[59444, 1582, 1799, 33, 54, "Input"],
1765
+ Cell[61246, 1617, 1557, 36, 54, "Output"]
1766
+ }, Open ]],
1767
+ Cell[CellGroupData[{
1768
+ Cell[62840, 1658, 583, 13, 54, "Input"],
1769
+ Cell[63426, 1673, 797, 15, 285, "Output"]
1770
+ }, Open ]],
1771
+ Cell[64238, 1691, 170, 2, 30, "Text"]
1772
+ }, Open ]]
1773
+ }, Open ]]
1774
+ }
1775
+ ]
1776
+ *)
1777
+