@calcit/procs 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/.compact-inc.cirru +0 -20
- package/.vscode/launch.json +0 -157
- package/.vscode/settings.json +0 -3
- package/demos/.calcit-runner.cirru +0 -389
- package/demos/calcit.cirru +0 -2555
- package/demos/compact.cirru +0 -469
- package/demos/test_request.json +0 -1
- package/profile.json +0 -1
package/lib/package.json
CHANGED
package/package.json
CHANGED
package/.compact-inc.cirru
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{}
|
|
3
|
-
|added $ {}
|
|
4
|
-
|changed $ {}
|
|
5
|
-
|quaternion.test $ {}
|
|
6
|
-
:changed-defs $ {}
|
|
7
|
-
|test-add $ quote
|
|
8
|
-
deftest test-add
|
|
9
|
-
testing "|multiply quaternion" $ is
|
|
10
|
-
= (:: :quaternion -60 12 30 24)
|
|
11
|
-
&q* (:: :quaternion 1 2 3 4) (:: :quaternion 5 6 7 8)
|
|
12
|
-
testing "\"add complex"
|
|
13
|
-
is $ = (:: :complex 9 12)
|
|
14
|
-
c+ (:: :complex 1 2) (:: :complex 3 4) (:: :complex 5 6)
|
|
15
|
-
is $ = (:: :complex 4 6)
|
|
16
|
-
c+ (:: :complex 1 2) (:: :complex 3 4)
|
|
17
|
-
testing "🚀 Updated demo test case" $ is
|
|
18
|
-
= (:: :complex 10 10)
|
|
19
|
-
c+ (:: :complex 3 4) (:: :complex 7 6)
|
|
20
|
-
|removed $ #{}
|
package/.vscode/launch.json
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"setupCommands": [ { "text": "-enable-pretty-printing" } ],
|
|
7
|
-
"configurations": [
|
|
8
|
-
{
|
|
9
|
-
"type": "lldb",
|
|
10
|
-
"request": "launch",
|
|
11
|
-
"name": "Debug unit tests in library 'calcit'",
|
|
12
|
-
"cargo": {
|
|
13
|
-
"args": [
|
|
14
|
-
"test",
|
|
15
|
-
"--no-run",
|
|
16
|
-
"--lib",
|
|
17
|
-
"--package=calcit"
|
|
18
|
-
],
|
|
19
|
-
"filter": {
|
|
20
|
-
"name": "calcit",
|
|
21
|
-
"kind": "lib"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"args": [],
|
|
25
|
-
"cwd": "${workspaceFolder}"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"type": "lldb",
|
|
29
|
-
"request": "launch",
|
|
30
|
-
"name": "Debug executable 'cr'",
|
|
31
|
-
"cargo": {
|
|
32
|
-
"args": [
|
|
33
|
-
"build",
|
|
34
|
-
"--bin=cr",
|
|
35
|
-
"--package=calcit"
|
|
36
|
-
],
|
|
37
|
-
"filter": {
|
|
38
|
-
"name": "cr",
|
|
39
|
-
"kind": "bin"
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
"args": [],
|
|
44
|
-
"cwd": "${workspaceFolder}"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"type": "lldb",
|
|
48
|
-
"request": "launch",
|
|
49
|
-
"name": "Debug rs demo",
|
|
50
|
-
"cargo": {
|
|
51
|
-
"args": [
|
|
52
|
-
"build",
|
|
53
|
-
"--package=calcit",
|
|
54
|
-
"--bin=cr"
|
|
55
|
-
],
|
|
56
|
-
"filter": {
|
|
57
|
-
"name": "cr",
|
|
58
|
-
"kind": "bin"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"args": ["calcit/test.cirru", "-1"],
|
|
62
|
-
"cwd": "${workspaceFolder}"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"type": "lldb",
|
|
66
|
-
"request": "launch",
|
|
67
|
-
"name": "Debug js demo",
|
|
68
|
-
"cargo": {
|
|
69
|
-
"args": [
|
|
70
|
-
"build",
|
|
71
|
-
"--package=calcit",
|
|
72
|
-
"--bin=cr"
|
|
73
|
-
],
|
|
74
|
-
"filter": {
|
|
75
|
-
"name": "cr",
|
|
76
|
-
"kind": "bin"
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"args": ["calcit/test.cirru", "-1", "--emit-js"],
|
|
80
|
-
"cwd": "${workspaceFolder}"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"type": "lldb",
|
|
84
|
-
"request": "launch",
|
|
85
|
-
"name": "Debug editor demo",
|
|
86
|
-
"cargo": {
|
|
87
|
-
"args": [
|
|
88
|
-
"build",
|
|
89
|
-
"--package=calcit",
|
|
90
|
-
"--bin=cr"
|
|
91
|
-
],
|
|
92
|
-
"filter": {
|
|
93
|
-
"name": "cr",
|
|
94
|
-
"kind": "bin"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
"args": ["--emit-js", "--emit-path", "out-page/", "--entry", "client"],
|
|
98
|
-
"cwd": "/Users/chenyong/repo/calcit-lang/editor/"
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"type": "lldb",
|
|
102
|
-
"request": "launch",
|
|
103
|
-
"name": "Debug unit tests in executable 'cr'",
|
|
104
|
-
"cargo": {
|
|
105
|
-
"args": [
|
|
106
|
-
"test",
|
|
107
|
-
"--no-run",
|
|
108
|
-
"--bin=cr",
|
|
109
|
-
"--package=calcit"
|
|
110
|
-
],
|
|
111
|
-
"filter": {
|
|
112
|
-
"name": "cr",
|
|
113
|
-
"kind": "bin"
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
"args": [],
|
|
117
|
-
"cwd": "${workspaceFolder}"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"type": "lldb",
|
|
121
|
-
"request": "launch",
|
|
122
|
-
"name": "Debug executable 'bundle_calcit'",
|
|
123
|
-
"cargo": {
|
|
124
|
-
"args": [
|
|
125
|
-
"build",
|
|
126
|
-
"--bin=bundle_calcit",
|
|
127
|
-
"--package=calcit"
|
|
128
|
-
],
|
|
129
|
-
"filter": {
|
|
130
|
-
"name": "bundle_calcit",
|
|
131
|
-
"kind": "bin"
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
"args": [],
|
|
135
|
-
"cwd": "${workspaceFolder}"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
"type": "lldb",
|
|
139
|
-
"request": "launch",
|
|
140
|
-
"name": "Debug unit tests in executable 'bundle_calcit'",
|
|
141
|
-
"cargo": {
|
|
142
|
-
"args": [
|
|
143
|
-
"test",
|
|
144
|
-
"--no-run",
|
|
145
|
-
"--bin=bundle_calcit",
|
|
146
|
-
"--package=calcit"
|
|
147
|
-
],
|
|
148
|
-
"filter": {
|
|
149
|
-
"name": "bundle_calcit",
|
|
150
|
-
"kind": "bin"
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
"args": [],
|
|
154
|
-
"cwd": "${workspaceFolder}"
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
}
|
package/.vscode/settings.json
DELETED
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{} (:package |quaternion)
|
|
3
|
-
:configs $ {} (:init-fn |quaternion.test/main!) (:reload-fn |quaternion.test/reload!) (:version |0.2.1)
|
|
4
|
-
:modules $ [] |calcit-test/
|
|
5
|
-
:entries $ {}
|
|
6
|
-
:test $ {} (:init-fn |quaternion.test/main!) (:reload-fn |quaternion.test/reload!)
|
|
7
|
-
:modules $ [] |calcit-test/
|
|
8
|
-
:files $ {}
|
|
9
|
-
|quaternion.complex $ %{} :FileEntry
|
|
10
|
-
:defs $ {}
|
|
11
|
-
|%complex $ %{} :CodeEntry (:doc |)
|
|
12
|
-
:code $ quote
|
|
13
|
-
defrecord! %complex (:+ &c+) (:- &c-) (:* &c*) (:length c-length) (:scale c-scale) (:conjugate c-conjugate)
|
|
14
|
-
:to-js $ fn (self)
|
|
15
|
-
tag-match self $
|
|
16
|
-
:complex x y
|
|
17
|
-
js-array x y
|
|
18
|
-
|&c* $ %{} :CodeEntry (:doc |)
|
|
19
|
-
:code $ quote
|
|
20
|
-
defn &c* (a b)
|
|
21
|
-
tag-match a $
|
|
22
|
-
:complex x0 y0
|
|
23
|
-
tag-match b $
|
|
24
|
-
:complex x1 y1
|
|
25
|
-
complex
|
|
26
|
-
&- (&* x0 x1) (&* y0 y1)
|
|
27
|
-
&+ (&* x0 y1) (&* x1 y0)
|
|
28
|
-
|&c+ $ %{} :CodeEntry (:doc |)
|
|
29
|
-
:code $ quote
|
|
30
|
-
defn &c+ (a b)
|
|
31
|
-
tag-match a $
|
|
32
|
-
:complex x0 y0
|
|
33
|
-
tag-match b $
|
|
34
|
-
:complex x1 y1
|
|
35
|
-
complex (&+ x0 x1) (&+ y0 y1)
|
|
36
|
-
|&c- $ %{} :CodeEntry (:doc |)
|
|
37
|
-
:code $ quote
|
|
38
|
-
defn &c- (a b)
|
|
39
|
-
tag-match a $
|
|
40
|
-
:complex x0 y0
|
|
41
|
-
tag-match b $
|
|
42
|
-
:complex x1 y1
|
|
43
|
-
complex (&- x0 x1) (&- y0 y1)
|
|
44
|
-
|c* $ %{} :CodeEntry (:doc |)
|
|
45
|
-
:code $ quote
|
|
46
|
-
defn c* (& xs)
|
|
47
|
-
foldl (rest xs) (first xs)
|
|
48
|
-
fn (acc x) (&c* acc x)
|
|
49
|
-
|c+ $ %{} :CodeEntry (:doc |)
|
|
50
|
-
:code $ quote
|
|
51
|
-
defn c+ (& xs)
|
|
52
|
-
foldl (rest xs) (first xs)
|
|
53
|
-
fn (acc x) (&c+ acc x)
|
|
54
|
-
|c-conjugate $ %{} :CodeEntry (:doc |)
|
|
55
|
-
:code $ quote
|
|
56
|
-
defn c-conjugate (a)
|
|
57
|
-
tag-match a $
|
|
58
|
-
:complex x y
|
|
59
|
-
complex (&- 0 x) y
|
|
60
|
-
|c-length $ %{} :CodeEntry (:doc |)
|
|
61
|
-
:code $ quote
|
|
62
|
-
defn c-length (v)
|
|
63
|
-
tag-match v $
|
|
64
|
-
:complex x y
|
|
65
|
-
sqrt $ &+ (&* x x) (&* y y)
|
|
66
|
-
|c-length2 $ %{} :CodeEntry (:doc |)
|
|
67
|
-
:code $ quote
|
|
68
|
-
defn c-length2 (v)
|
|
69
|
-
tag-match v $
|
|
70
|
-
:: :complex x y
|
|
71
|
-
&+ (&* x x) (&* y y)
|
|
72
|
-
|c-scale $ %{} :CodeEntry (:doc |)
|
|
73
|
-
:code $ quote
|
|
74
|
-
defn c-scale (v n)
|
|
75
|
-
tag-match v $
|
|
76
|
-
:complex x y
|
|
77
|
-
complex (&* n x) (&* n y)
|
|
78
|
-
|complex $ %{} :CodeEntry (:doc |)
|
|
79
|
-
:code $ quote
|
|
80
|
-
defn complex (x y) (%:: %complex :complex x y)
|
|
81
|
-
:ns $ %{} :CodeEntry (:doc |)
|
|
82
|
-
:code $ quote (ns quaternion.complex)
|
|
83
|
-
|quaternion.core $ %{} :FileEntry
|
|
84
|
-
:defs $ {}
|
|
85
|
-
|%quaternion $ %{} :CodeEntry (:doc |)
|
|
86
|
-
:code $ quote
|
|
87
|
-
defrecord! %quaternion (:+ &q+) (:- &q-) (:* &q*) (:inverse q-inverse) (:conjugate q-conjugate) (:length q-length) (:scale q-scale)
|
|
88
|
-
:to-js $ fn (self)
|
|
89
|
-
tag-match self $
|
|
90
|
-
:quaternion s x y z
|
|
91
|
-
js-array x y z s
|
|
92
|
-
:to-v3 $ fn (self)
|
|
93
|
-
tag-match self $
|
|
94
|
-
:quaternion s x y z
|
|
95
|
-
do
|
|
96
|
-
if (not= s 0) (eprintln "\"s is not zero in quaternion when convering")
|
|
97
|
-
v3 x y z
|
|
98
|
-
:from-v3 $ fn (v)
|
|
99
|
-
tag-match v $
|
|
100
|
-
:v3 x y z
|
|
101
|
-
quaternion 0 x y z
|
|
102
|
-
|&q* $ %{} :CodeEntry (:doc |)
|
|
103
|
-
:code $ quote
|
|
104
|
-
defn &q* (a b)
|
|
105
|
-
tag-match a $
|
|
106
|
-
:quaternion w1 x1 y1 z1
|
|
107
|
-
tag-match b $
|
|
108
|
-
:quaternion w2 x2 y2 z2
|
|
109
|
-
quaternion
|
|
110
|
-
-> (&* w1 w2)
|
|
111
|
-
&- $ &* x1 x2
|
|
112
|
-
&- $ &* y1 y2
|
|
113
|
-
&- $ &* z1 z2
|
|
114
|
-
-> (&* w1 x2)
|
|
115
|
-
&+ $ &* x1 w2
|
|
116
|
-
&+ $ &* y1 z2
|
|
117
|
-
&- $ &* z1 y2
|
|
118
|
-
-> (&* w1 y2)
|
|
119
|
-
&- $ &* x1 z2
|
|
120
|
-
&+ $ &* y1 w2
|
|
121
|
-
&+ $ &* z1 x2
|
|
122
|
-
-> (&* w1 z2)
|
|
123
|
-
&+ $ &* x1 y2
|
|
124
|
-
&- $ &* y1 x2
|
|
125
|
-
&+ $ &* z1 w2
|
|
126
|
-
|&q+ $ %{} :CodeEntry (:doc |)
|
|
127
|
-
:code $ quote
|
|
128
|
-
defn &q+ (a b)
|
|
129
|
-
tag-match a $
|
|
130
|
-
:quaternion w x y z
|
|
131
|
-
tag-match b $
|
|
132
|
-
:quaternion w1 x1 y1 z1
|
|
133
|
-
quaternion (&+ w w1) (&+ x x1) (&+ y y1) (&+ z z1)
|
|
134
|
-
|&q- $ %{} :CodeEntry (:doc |)
|
|
135
|
-
:code $ quote
|
|
136
|
-
defn &q- (a b)
|
|
137
|
-
tag-match a $
|
|
138
|
-
:quaternion w x y z
|
|
139
|
-
tag-match b $
|
|
140
|
-
:quaternion w1 x1 y1 z1
|
|
141
|
-
quaternion (&- w w1) (&- x x1) (&- y y1) (&- z z1)
|
|
142
|
-
|q+ $ %{} :CodeEntry (:doc |)
|
|
143
|
-
:code $ quote
|
|
144
|
-
defn q+ (& xs)
|
|
145
|
-
foldl xs (quaternion 0 0 0 0)
|
|
146
|
-
fn (acc x) (&q+ acc x)
|
|
147
|
-
|q- $ %{} :CodeEntry (:doc |)
|
|
148
|
-
:code $ quote
|
|
149
|
-
defn q- (& xs)
|
|
150
|
-
foldl (rest xs) (first xs)
|
|
151
|
-
fn (acc x) (&q- acc x)
|
|
152
|
-
|q-conjugate $ %{} :CodeEntry (:doc |)
|
|
153
|
-
:code $ quote
|
|
154
|
-
defn q-conjugate (a)
|
|
155
|
-
tag-match a $
|
|
156
|
-
:quaternion w x y z
|
|
157
|
-
quaternion w (&- 0 x) (&- 0 y) (&- 0 z)
|
|
158
|
-
|q-inverse $ %{} :CodeEntry (:doc |)
|
|
159
|
-
:code $ quote
|
|
160
|
-
defn q-inverse (a)
|
|
161
|
-
let
|
|
162
|
-
l $ q-length2 a
|
|
163
|
-
if (&= l 0) (eprintln "\"length is zero:" a)
|
|
164
|
-
q-scale (q-conjugate a) (&/ 1 l)
|
|
165
|
-
|q-length $ %{} :CodeEntry (:doc |)
|
|
166
|
-
:code $ quote
|
|
167
|
-
defn q-length (a)
|
|
168
|
-
tag-match a $
|
|
169
|
-
:quaternion w x y z
|
|
170
|
-
sqrt $ -> (&* x x)
|
|
171
|
-
&+ $ &* y y
|
|
172
|
-
&+ $ &* z z
|
|
173
|
-
&+ $ &* w w
|
|
174
|
-
|q-length2 $ %{} :CodeEntry (:doc |)
|
|
175
|
-
:code $ quote
|
|
176
|
-
defn q-length2 (a)
|
|
177
|
-
tag-match a $
|
|
178
|
-
:quaternion w x y z
|
|
179
|
-
-> (&* x x)
|
|
180
|
-
&+ $ &* y y
|
|
181
|
-
&+ $ &* z z
|
|
182
|
-
&+ $ &* w w
|
|
183
|
-
|q-scale $ %{} :CodeEntry (:doc |)
|
|
184
|
-
:code $ quote
|
|
185
|
-
defn q-scale (v n)
|
|
186
|
-
tag-match v $
|
|
187
|
-
:quaternion w x y z
|
|
188
|
-
quaternion (&* n w) (&* n x) (&* n y) (&* n z)
|
|
189
|
-
|quaternion $ %{} :CodeEntry (:doc |)
|
|
190
|
-
:code $ quote
|
|
191
|
-
defn quaternion (s x y z) (%:: %quaternion :quaternion s x y z)
|
|
192
|
-
:ns $ %{} :CodeEntry (:doc |)
|
|
193
|
-
:code $ quote
|
|
194
|
-
ns quaternion.core $ :require
|
|
195
|
-
quaternion.vector :refer $ v3
|
|
196
|
-
|quaternion.test $ %{} :FileEntry
|
|
197
|
-
:defs $ {}
|
|
198
|
-
|main! $ %{} :CodeEntry (:doc |)
|
|
199
|
-
:code $ quote
|
|
200
|
-
defn main! () $ run-tests
|
|
201
|
-
|reload! $ %{} :CodeEntry (:doc |)
|
|
202
|
-
:code $ quote
|
|
203
|
-
defn reload! () (println "\"🔄 Hot reload triggered! Running demos tests...") (run-tests)
|
|
204
|
-
|run-tests $ %{} :CodeEntry (:doc |)
|
|
205
|
-
:code $ quote
|
|
206
|
-
defn run-tests () (reset! *quit-on-failure? true) (test-add) (test-v-scale) (test-multiply) (test-complex) (test-v3) (test-quaternion)
|
|
207
|
-
|test-add $ %{} :CodeEntry (:doc |)
|
|
208
|
-
:code $ quote
|
|
209
|
-
deftest test-add
|
|
210
|
-
testing "|multiply quaternion" $ is
|
|
211
|
-
= (:: :quaternion -60 12 30 24)
|
|
212
|
-
&q* (:: :quaternion 1 2 3 4) (:: :quaternion 5 6 7 8)
|
|
213
|
-
testing "\"add complex"
|
|
214
|
-
is $ = (:: :complex 9 12)
|
|
215
|
-
c+ (:: :complex 1 2) (:: :complex 3 4) (:: :complex 5 6)
|
|
216
|
-
is $ = (:: :complex 4 6)
|
|
217
|
-
c+ (:: :complex 1 2) (:: :complex 3 4)
|
|
218
|
-
testing "🚀 Updated demo test case"
|
|
219
|
-
is $ = (:: :complex 10 10)
|
|
220
|
-
c+ (:: :complex 3 4) (:: :complex 7 6)
|
|
221
|
-
|test-complex $ %{} :CodeEntry (:doc |)
|
|
222
|
-
:code $ quote
|
|
223
|
-
deftest test-complex $ testing "\"trying complex values"
|
|
224
|
-
is $ = (complex -5 10)
|
|
225
|
-
.* (complex 1 2) (complex 3 4)
|
|
226
|
-
is $ = (complex -5 10)
|
|
227
|
-
.* (complex 1 2) (complex 3 4)
|
|
228
|
-
is $ = (complex -85 20)
|
|
229
|
-
-> (complex 1 2)
|
|
230
|
-
.* $ complex 3 4
|
|
231
|
-
.* $ complex 5 6
|
|
232
|
-
|test-multiply $ %{} :CodeEntry (:doc |)
|
|
233
|
-
:code $ quote
|
|
234
|
-
deftest test-multiply $ testing "\"multiply complex"
|
|
235
|
-
is $ = (:: :complex -5 10)
|
|
236
|
-
&c* (:: :complex 1 2) (:: :complex 3 4)
|
|
237
|
-
is $ = (:: :complex -5 10)
|
|
238
|
-
c* (:: :complex 1 2) (:: :complex 3 4)
|
|
239
|
-
is $ = (:: :complex -85 20)
|
|
240
|
-
c* (:: :complex 1 2) (:: :complex 3 4) (:: :complex 5 6)
|
|
241
|
-
|test-quaternion $ %{} :CodeEntry (:doc |)
|
|
242
|
-
:code $ quote
|
|
243
|
-
deftest test-quaternion
|
|
244
|
-
testing "\"quaternion demos" $ is
|
|
245
|
-
= (quaternion 4 6 8 10)
|
|
246
|
-
.+ (quaternion 0 1 2 3) (quaternion 4 5 6 7)
|
|
247
|
-
testing "\"v3 to quaternion"
|
|
248
|
-
is $ = (v3 6 8 10)
|
|
249
|
-
.to-v3 $ quaternion 4 6 8 10
|
|
250
|
-
is $ =
|
|
251
|
-
:from-v3 %quaternion
|
|
252
|
-
v3 6 8 10
|
|
253
|
-
quaternion 0 6 8 10
|
|
254
|
-
testing "\"add multiple q" $ is
|
|
255
|
-
= (quaternion 6 6 6 6)
|
|
256
|
-
q+ (quaternion 1 1 1 1) (quaternion 2 2 2 2) (quaternion 3 3 3 3)
|
|
257
|
-
|test-v-scale $ %{} :CodeEntry (:doc |)
|
|
258
|
-
:code $ quote
|
|
259
|
-
deftest test-v-scale $ testing |v-scale
|
|
260
|
-
is $ =
|
|
261
|
-
v-scale (:: :complex 1 2) 3
|
|
262
|
-
:: :complex 3 6
|
|
263
|
-
is $ =
|
|
264
|
-
v-scale (:: :v3 1 2 3) 4
|
|
265
|
-
:: :v3 4 8 12
|
|
266
|
-
is $ =
|
|
267
|
-
c-scale (:: :complex 1 2) 3
|
|
268
|
-
:: :complex 3 6
|
|
269
|
-
|test-v3 $ %{} :CodeEntry (:doc |)
|
|
270
|
-
:code $ quote
|
|
271
|
-
deftest test-v3 $ testing "\"trying v3 values"
|
|
272
|
-
is $ = (v3 5 7 9)
|
|
273
|
-
.+ (v3 1 2 3) (v3 4 5 6)
|
|
274
|
-
is $ = 0
|
|
275
|
-
.dot (v3 0 1 0) (v3 1 0 0)
|
|
276
|
-
is $ = (v3 0 0 -1)
|
|
277
|
-
.cross (v3 0 1 0) (v3 1 0 0)
|
|
278
|
-
is $ = (v3 12 15 18)
|
|
279
|
-
v+ (v3 1 2 3) (v3 4 5 6) (v3 7 8 9)
|
|
280
|
-
is $ = (sqrt 14)
|
|
281
|
-
.length $ v3 1 2 3
|
|
282
|
-
:ns $ %{} :CodeEntry (:doc |)
|
|
283
|
-
:code $ quote
|
|
284
|
-
ns quaternion.test $ :require
|
|
285
|
-
calcit-test.core :refer $ deftest testing is *quit-on-failure?
|
|
286
|
-
quaternion.core :refer $ &q* quaternion %quaternion q+
|
|
287
|
-
quaternion.vector :refer $ v-scale v3 v+
|
|
288
|
-
quaternion.complex :refer $ c+ c* &c* c-scale complex
|
|
289
|
-
|quaternion.vector $ %{} :FileEntry
|
|
290
|
-
:defs $ {}
|
|
291
|
-
|%v3 $ %{} :CodeEntry (:doc |)
|
|
292
|
-
:code $ quote
|
|
293
|
-
defrecord! %v3 (:+ &v+) (:- &v-) (:cross v-cross) (:dot v-dot) (:length v-length) (:normalize v-normalize) (:scale v-scale)
|
|
294
|
-
:to-js $ fn (self)
|
|
295
|
-
tag-match self $
|
|
296
|
-
:v3 x y z
|
|
297
|
-
js-array x y z
|
|
298
|
-
:reflect v-reflect
|
|
299
|
-
|&v+ $ %{} :CodeEntry (:doc |)
|
|
300
|
-
:code $ quote
|
|
301
|
-
defn &v+ (a b)
|
|
302
|
-
tag-match a $
|
|
303
|
-
:v3 x y z
|
|
304
|
-
tag-match b $
|
|
305
|
-
:v3 x2 y2 z2
|
|
306
|
-
v3 (&+ x x2) (&+ y y2) (&+ z z2)
|
|
307
|
-
|&v- $ %{} :CodeEntry (:doc |)
|
|
308
|
-
:code $ quote
|
|
309
|
-
defn &v- (a b)
|
|
310
|
-
tag-match a $
|
|
311
|
-
:v3 x y z
|
|
312
|
-
tag-match b $
|
|
313
|
-
:v3 x2 y2 z2
|
|
314
|
-
v3 (&- x x2) (&- y y2) (&- z z2)
|
|
315
|
-
|v+ $ %{} :CodeEntry (:doc |)
|
|
316
|
-
:code $ quote
|
|
317
|
-
defn v+ (& xs)
|
|
318
|
-
foldl xs (v3 0 0 0)
|
|
319
|
-
fn (acc x) (&v+ acc x)
|
|
320
|
-
|v- $ %{} :CodeEntry (:doc |)
|
|
321
|
-
:code $ quote
|
|
322
|
-
defn v- (& xs)
|
|
323
|
-
foldl (rest xs) (first xs)
|
|
324
|
-
fn (acc x) (&v- acc x)
|
|
325
|
-
|v-cross $ %{} :CodeEntry (:doc |)
|
|
326
|
-
:code $ quote
|
|
327
|
-
defn v-cross (v1 v2)
|
|
328
|
-
tag-match v1 $
|
|
329
|
-
:v3 x1 y1 z1
|
|
330
|
-
tag-match v2 $
|
|
331
|
-
:v3 x2 y2 z2
|
|
332
|
-
v3
|
|
333
|
-
&- (&* y1 z2) (&* y2 z1)
|
|
334
|
-
&- (&* x2 z1) (&* x1 z2)
|
|
335
|
-
&- (&* x1 y2) (&* x2 y1)
|
|
336
|
-
|v-dot $ %{} :CodeEntry (:doc |)
|
|
337
|
-
:code $ quote
|
|
338
|
-
defn v-dot (v1 v2)
|
|
339
|
-
tag-match v1 $
|
|
340
|
-
:v3 x1 y1 z1
|
|
341
|
-
tag-match v2 $
|
|
342
|
-
:v3 x2 y2 z2
|
|
343
|
-
-> (&* x1 x2)
|
|
344
|
-
&+ $ &* y1 y2
|
|
345
|
-
&+ $ &* z1 z2
|
|
346
|
-
|v-length $ %{} :CodeEntry (:doc |)
|
|
347
|
-
:code $ quote
|
|
348
|
-
defn v-length (a)
|
|
349
|
-
tag-match a $
|
|
350
|
-
:v3 x y z
|
|
351
|
-
sqrt $ -> (&* x x)
|
|
352
|
-
&+ $ &* y y
|
|
353
|
-
&+ $ &* z z
|
|
354
|
-
|v-normalize $ %{} :CodeEntry (:doc |)
|
|
355
|
-
:code $ quote
|
|
356
|
-
defn v-normalize (v)
|
|
357
|
-
tag-match v $
|
|
358
|
-
:v3 x y z
|
|
359
|
-
let
|
|
360
|
-
length $ sqrt
|
|
361
|
-
-> (&* x x)
|
|
362
|
-
&+ $ &* y y
|
|
363
|
-
&+ $ &* z z
|
|
364
|
-
if (&= length 0) (eprintln "\"Unexpected zero length:" length)
|
|
365
|
-
v-scale v $ &/ 1 length
|
|
366
|
-
|v-reflect $ %{} :CodeEntry (:doc |)
|
|
367
|
-
:code $ quote
|
|
368
|
-
defn v-reflect (a base)
|
|
369
|
-
let
|
|
370
|
-
base0 $ v-normalize base
|
|
371
|
-
l $ v-dot a base0
|
|
372
|
-
a-shadow $ v-scale base0 l
|
|
373
|
-
b $ &v- a a-shadow
|
|
374
|
-
&v- a-shadow b
|
|
375
|
-
|v-scale $ %{} :CodeEntry (:doc |)
|
|
376
|
-
:code $ quote
|
|
377
|
-
defn v-scale (v n)
|
|
378
|
-
tag-match v
|
|
379
|
-
:v3 x y z
|
|
380
|
-
v3 (&* n x) (&* n y) (&* n z)
|
|
381
|
-
(:complex x y)
|
|
382
|
-
complex (&* n x) (&* n y)
|
|
383
|
-
|v3 $ %{} :CodeEntry (:doc |)
|
|
384
|
-
:code $ quote
|
|
385
|
-
defn v3 (x y z) (%:: %v3 :v3 x y z)
|
|
386
|
-
:ns $ %{} :CodeEntry (:doc |)
|
|
387
|
-
:code $ quote
|
|
388
|
-
ns quaternion.vector $ :require
|
|
389
|
-
quaternion.complex :refer $ complex
|