triangular 0.0.1

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.
@@ -0,0 +1,58 @@
1
+ solid model
2
+ facet normal -0.0 1.0 -0.0
3
+ outer loop
4
+ vertex -1.0 1.0 1.0
5
+ vertex 0.999999999999999 1.0 -1.0
6
+ vertex -1.0 1.0 -1.0
7
+ endloop
8
+ endfacet
9
+ facet normal -0.0 1.0 -0.0
10
+ outer loop
11
+ vertex 0.999999999999999 1.0 -1.0
12
+ vertex -1.0 1.0 1.0
13
+ vertex 0.999999999999999 1.0 1.0
14
+ endloop
15
+ endfacet
16
+ facet normal 1.0 -0.0 -0.0
17
+ outer loop
18
+ vertex 0.999999999999999 1.0 -1.0
19
+ vertex 0.999999999999999 -1.0 1.0
20
+ vertex 0.999999999999999 -1.0 -1.0
21
+ endloop
22
+ endfacet
23
+ facet normal 1.0 -0.0 -0.0
24
+ outer loop
25
+ vertex 0.999999999999999 -1.0 1.0
26
+ vertex 0.999999999999999 1.0 -1.0
27
+ vertex 0.999999999999999 1.0 1.0
28
+ endloop
29
+ endfacet
30
+ facet normal 0.0 -1.0 0.0
31
+ outer loop
32
+ vertex 0.999999999999999 -1.0 1.0
33
+ vertex -1.0 -1.0 -1.0
34
+ vertex 0.999999999999999 -1.0 -1.0
35
+ endloop
36
+ endfacet
37
+ facet normal 0.0 -1.0 0.0
38
+ outer loop
39
+ vertex -1.0 -1.0 -1.0
40
+ vertex 0.999999999999999 -1.0 1.0
41
+ vertex -1.0 -1.0 1.0
42
+ endloop
43
+ endfacet
44
+ facet normal -1.0 0.0 0.0
45
+ outer loop
46
+ vertex -1.0 1.0 1.0
47
+ vertex -1.0 -1.0 -1.0
48
+ vertex -1.0 -1.0 1.0
49
+ endloop
50
+ endfacet
51
+ facet normal -1.0 0.0 0.0
52
+ outer loop
53
+ vertex -1.0 -1.0 -1.0
54
+ vertex -1.0 1.0 1.0
55
+ vertex -1.0 1.0 -1.0
56
+ endloop
57
+ endfacet
58
+ endsolid model
@@ -0,0 +1,310 @@
1
+ solid y-axis-spacer
2
+ facet normal 0.0 0.0 -1.0
3
+ outer loop
4
+ vertex 16.5 0.0 -0.75
5
+ vertex 0.0 -9.5 -0.75
6
+ vertex 0.0 0.0 -0.75
7
+ endloop
8
+ endfacet
9
+ facet normal 0.0 0.0 -1.0
10
+ outer loop
11
+ vertex 0.0 -9.5 -0.75
12
+ vertex 16.5 0.0 -0.75
13
+ vertex 16.5 -9.5 -0.75
14
+ endloop
15
+ endfacet
16
+ facet normal -0.0 -1.0 -0.0
17
+ outer loop
18
+ vertex 16.5 -9.5 0.0
19
+ vertex 0.0 -9.5 -0.75
20
+ vertex 16.5 -9.5 -0.75
21
+ endloop
22
+ endfacet
23
+ facet normal -0.0 -1.0 -0.0
24
+ outer loop
25
+ vertex 0.0 -9.5 -0.75
26
+ vertex 16.5 -9.5 0.0
27
+ vertex 0.0 -9.5 0.0
28
+ endloop
29
+ endfacet
30
+ facet normal -0.0 1.0 0.0
31
+ outer loop
32
+ vertex 0.0 0.0 0.0
33
+ vertex 16.5 0.0 -0.75
34
+ vertex 0.0 0.0 -0.75
35
+ endloop
36
+ endfacet
37
+ facet normal -0.0 1.0 0.0
38
+ outer loop
39
+ vertex 16.5 0.0 -0.75
40
+ vertex 0.0 0.0 0.0
41
+ vertex 16.5 0.0 0.0
42
+ endloop
43
+ endfacet
44
+ facet normal -1.0 0.0 0.0
45
+ outer loop
46
+ vertex 0.0 -2.13 0.0
47
+ vertex 0.0 -7.37 -0.13
48
+ vertex 0.0 -7.37 0.0
49
+ endloop
50
+ endfacet
51
+ facet normal -1.0 0.0 0.0
52
+ outer loop
53
+ vertex 0.0 0.0 0.0
54
+ vertex 0.0 -1.87 -0.13
55
+ vertex 0.0 -1.87 0.0
56
+ endloop
57
+ endfacet
58
+ facet normal -1.0 0.0 0.0
59
+ outer loop
60
+ vertex 0.0 -7.63 0.0
61
+ vertex 0.0 -9.5 -0.75
62
+ vertex 0.0 -9.5 0.0
63
+ endloop
64
+ endfacet
65
+ facet normal -1.0 0.0 0.0
66
+ outer loop
67
+ vertex 0.0 -9.5 -0.75
68
+ vertex 0.0 -7.63 0.0
69
+ vertex 0.0 -7.63 -0.13
70
+ endloop
71
+ endfacet
72
+ facet normal -1.0 0.0 0.0
73
+ outer loop
74
+ vertex 0.0 -9.5 -0.75
75
+ vertex 0.0 -7.63 -0.13
76
+ vertex 0.0 0.0 -0.75
77
+ endloop
78
+ endfacet
79
+ facet normal -1.0 0.0 0.0
80
+ outer loop
81
+ vertex 0.0 0.0 -0.75
82
+ vertex 0.0 -7.63 -0.13
83
+ vertex 0.0 -7.37 -0.13
84
+ endloop
85
+ endfacet
86
+ facet normal -1.0 0.0 0.0
87
+ outer loop
88
+ vertex 0.0 0.0 -0.75
89
+ vertex 0.0 -7.37 -0.13
90
+ vertex 0.0 -2.13 -0.13
91
+ endloop
92
+ endfacet
93
+ facet normal -1.0 0.0 0.0
94
+ outer loop
95
+ vertex 0.0 -2.13 -0.13
96
+ vertex 0.0 -7.37 -0.13
97
+ vertex 0.0 -2.13 0.0
98
+ endloop
99
+ endfacet
100
+ facet normal -1.0 0.0 0.0
101
+ outer loop
102
+ vertex 0.0 0.0 -0.75
103
+ vertex 0.0 -2.13 -0.13
104
+ vertex 0.0 -1.87 -0.13
105
+ endloop
106
+ endfacet
107
+ facet normal -1.0 0.0 0.0
108
+ outer loop
109
+ vertex 0.0 0.0 -0.75
110
+ vertex 0.0 -1.87 -0.13
111
+ vertex 0.0 0.0 0.0
112
+ endloop
113
+ endfacet
114
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
115
+ outer loop
116
+ vertex 16.5 0.0 -0.75
117
+ vertex 16.5 -9.5 0.0
118
+ vertex 16.5 -9.5 -0.75
119
+ endloop
120
+ endfacet
121
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
122
+ outer loop
123
+ vertex 16.5 -9.5 0.0
124
+ vertex 16.5 0.0 -0.75
125
+ vertex 16.5 -7.63 -0.13
126
+ endloop
127
+ endfacet
128
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
129
+ outer loop
130
+ vertex 16.5 -7.63 -0.13
131
+ vertex 16.5 0.0 -0.75
132
+ vertex 16.5 -7.37 -0.13
133
+ endloop
134
+ endfacet
135
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
136
+ outer loop
137
+ vertex 16.5 -7.37 -0.13
138
+ vertex 16.5 0.0 -0.75
139
+ vertex 16.5 -7.37 0.0
140
+ endloop
141
+ endfacet
142
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
143
+ outer loop
144
+ vertex 16.5 -7.37 0.0
145
+ vertex 16.5 0.0 -0.75
146
+ vertex 16.5 -2.13 -0.13
147
+ endloop
148
+ endfacet
149
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
150
+ outer loop
151
+ vertex 16.5 -2.13 -0.13
152
+ vertex 16.5 0.0 -0.75
153
+ vertex 16.5 -1.87 -0.13
154
+ endloop
155
+ endfacet
156
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
157
+ outer loop
158
+ vertex 16.5 -1.87 -0.13
159
+ vertex 16.5 0.0 -0.75
160
+ vertex 16.5 -1.87 0.0
161
+ endloop
162
+ endfacet
163
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
164
+ outer loop
165
+ vertex 16.5 -1.87 0.0
166
+ vertex 16.5 0.0 -0.75
167
+ vertex 16.5 0.0 0.0
168
+ endloop
169
+ endfacet
170
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
171
+ outer loop
172
+ vertex 16.5 -2.13 0.0
173
+ vertex 16.5 -7.37 0.0
174
+ vertex 16.5 -2.13 -0.13
175
+ endloop
176
+ endfacet
177
+ facet normal 1.0 -5.23431439438796e-32 -6.31593542897867e-15
178
+ outer loop
179
+ vertex 16.5 -7.63 0.0
180
+ vertex 16.5 -9.5 0.0
181
+ vertex 16.5 -7.63 -0.13
182
+ endloop
183
+ endfacet
184
+ facet normal -0.0 -0.0 1.0
185
+ outer loop
186
+ vertex 16.5 -1.87 0.0
187
+ vertex 0.0 0.0 0.0
188
+ vertex 0.0 -1.87 0.0
189
+ endloop
190
+ endfacet
191
+ facet normal -0.0 -0.0 1.0
192
+ outer loop
193
+ vertex 0.0 0.0 0.0
194
+ vertex 16.5 -1.87 0.0
195
+ vertex 16.5 0.0 0.0
196
+ endloop
197
+ endfacet
198
+ facet normal -0.0 -0.0 1.0
199
+ outer loop
200
+ vertex 16.5 -9.5 0.0
201
+ vertex 0.0 -7.63 0.0
202
+ vertex 0.0 -9.5 0.0
203
+ endloop
204
+ endfacet
205
+ facet normal -0.0 -0.0 1.0
206
+ outer loop
207
+ vertex 0.0 -7.63 0.0
208
+ vertex 16.5 -9.5 0.0
209
+ vertex 16.5 -7.63 0.0
210
+ endloop
211
+ endfacet
212
+ facet normal -0.0 -0.0 1.0
213
+ outer loop
214
+ vertex 16.5 -7.37 0.0
215
+ vertex 0.0 -2.13 0.0
216
+ vertex 0.0 -7.37 0.0
217
+ endloop
218
+ endfacet
219
+ facet normal -0.0 -0.0 1.0
220
+ outer loop
221
+ vertex 0.0 -2.13 0.0
222
+ vertex 16.5 -7.37 0.0
223
+ vertex 16.5 -2.13 0.0
224
+ endloop
225
+ endfacet
226
+ facet normal 0.0 0.0 -1.0
227
+ outer loop
228
+ vertex 16.5 -7.37 -0.13
229
+ vertex 0.0 -7.63 -0.13
230
+ vertex 0.0 -7.37 -0.13
231
+ endloop
232
+ endfacet
233
+ facet normal 0.0 0.0 -1.0
234
+ outer loop
235
+ vertex 0.0 -7.63 -0.13
236
+ vertex 16.5 -7.37 -0.13
237
+ vertex 16.5 -7.63 -0.13
238
+ endloop
239
+ endfacet
240
+ facet normal -0.0 1.0 0.0
241
+ outer loop
242
+ vertex 0.0 -7.37 0.0
243
+ vertex 16.5 -7.37 -0.13
244
+ vertex 0.0 -7.37 -0.13
245
+ endloop
246
+ endfacet
247
+ facet normal -0.0 1.0 0.0
248
+ outer loop
249
+ vertex 16.5 -7.37 -0.13
250
+ vertex 0.0 -7.37 0.0
251
+ vertex 16.5 -7.37 0.0
252
+ endloop
253
+ endfacet
254
+ facet normal -0.0 -1.0 -0.0
255
+ outer loop
256
+ vertex 16.5 -7.63 0.0
257
+ vertex 0.0 -7.63 -0.13
258
+ vertex 16.5 -7.63 -0.13
259
+ endloop
260
+ endfacet
261
+ facet normal -0.0 -1.0 -0.0
262
+ outer loop
263
+ vertex 0.0 -7.63 -0.13
264
+ vertex 16.5 -7.63 0.0
265
+ vertex 0.0 -7.63 0.0
266
+ endloop
267
+ endfacet
268
+ facet normal 0.0 0.0 -1.0
269
+ outer loop
270
+ vertex 16.5 -1.87 -0.13
271
+ vertex 0.0 -2.13 -0.13
272
+ vertex 0.0 -1.87 -0.13
273
+ endloop
274
+ endfacet
275
+ facet normal 0.0 0.0 -1.0
276
+ outer loop
277
+ vertex 0.0 -2.13 -0.13
278
+ vertex 16.5 -1.87 -0.13
279
+ vertex 16.5 -2.13 -0.13
280
+ endloop
281
+ endfacet
282
+ facet normal -0.0 1.0 0.0
283
+ outer loop
284
+ vertex 0.0 -1.87 0.0
285
+ vertex 16.5 -1.87 -0.13
286
+ vertex 0.0 -1.87 -0.13
287
+ endloop
288
+ endfacet
289
+ facet normal -0.0 1.0 0.0
290
+ outer loop
291
+ vertex 16.5 -1.87 -0.13
292
+ vertex 0.0 -1.87 0.0
293
+ vertex 16.5 -1.87 0.0
294
+ endloop
295
+ endfacet
296
+ facet normal -0.0 -1.0 -0.0
297
+ outer loop
298
+ vertex 16.5 -2.13 0.0
299
+ vertex 0.0 -2.13 -0.13
300
+ vertex 16.5 -2.13 -0.13
301
+ endloop
302
+ endfacet
303
+ facet normal -0.0 -1.0 -0.0
304
+ outer loop
305
+ vertex 0.0 -2.13 -0.13
306
+ vertex 16.5 -2.13 0.0
307
+ vertex 0.0 -2.13 0.0
308
+ endloop
309
+ endfacet
310
+ endsolid y-axis-spacer
@@ -0,0 +1,190 @@
1
+ require 'spec_helper'
2
+
3
+ describe Line do
4
+ describe "#intersects_z?" do
5
+ context "for a line that intersects the target Z plane" do
6
+ context "with a positive Z vector" do
7
+ before do
8
+ @line = Line.new(Vertex.new(0.0, 0.0, 0.0), Vertex.new(0.0, 0.0, 6.0))
9
+ end
10
+
11
+ it "should return true" do
12
+ @line.intersects_z?(3.0).should be_true
13
+ end
14
+ end
15
+
16
+ context "with a negative Z vector" do
17
+ before do
18
+ @line = Line.new(Vertex.new(0.0, 0.0, 6.0), Vertex.new(0.0, 0.0, 0.0))
19
+ end
20
+
21
+ it "should return true" do
22
+ @line.intersects_z?(3.0).should be_true
23
+ end
24
+ end
25
+ end
26
+
27
+ context "for a line that does not intersect the target Z plane" do
28
+ before do
29
+ @line = Line.new(Vertex.new(0.0, 0.0, 4.0), Vertex.new(0.0, 0.0, 6.0))
30
+ end
31
+
32
+ it "should return false" do
33
+ @line.intersects_z?(3.0).should be_false
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "#intersection_at_z" do
39
+ context "for a line that intersects the target Z plane" do
40
+ context "and is located at the origin" do
41
+ context "with a positive Z vector" do
42
+ before do
43
+ @line = Line.new(Vertex.new(0.0, 0.0, 0.0), Vertex.new(0.0, 0.0, 6.0))
44
+ end
45
+
46
+ it "should return a a Point" do
47
+ @line.intersection_at_z(3.0).should be_a Point
48
+ end
49
+
50
+ it "should return a Point representing the intersection" do
51
+ @line.intersection_at_z(3.0).x.should == 0.0
52
+ @line.intersection_at_z(3.0).y.should == 0.0
53
+ @line.intersection_at_z(3.0).z.should == 3.0
54
+ end
55
+ end
56
+
57
+ context "with a negative Z vector" do
58
+ before do
59
+ @line = Line.new(Vertex.new(0.0, 0.0, 6.0), Vertex.new(0.0, 0.0, 0.0))
60
+ end
61
+
62
+ it "should return a Point representing the intersection" do
63
+ @line.intersection_at_z(3.0).x.should == 0.0
64
+ @line.intersection_at_z(3.0).y.should == 0.0
65
+ @line.intersection_at_z(3.0).z.should == 3.0
66
+ end
67
+ end
68
+ end
69
+
70
+ context "and is located away from the origin" do
71
+ context "with a positive Z vector" do
72
+ before do
73
+ @line = Line.new(Vertex.new(7.0, 7.0, 1.0), Vertex.new(7.0, 7.0, 7.0))
74
+ end
75
+
76
+ it "should return a Point representing the intersection" do
77
+ @line.intersection_at_z(4.0).x.should == 7.0
78
+ @line.intersection_at_z(4.0).y.should == 7.0
79
+ @line.intersection_at_z(4.0).z.should == 4.0
80
+ end
81
+ end
82
+
83
+ context "with a negative Z vector" do
84
+ before do
85
+ @line = Line.new(Vertex.new(7.0, 7.0, 7.0), Vertex.new(1.0, 1.0, 1.0))
86
+ end
87
+
88
+ it "should return a Point representing the intersection" do
89
+ @line.intersection_at_z(4.0).x.should == 4.0
90
+ @line.intersection_at_z(4.0).y.should == 4.0
91
+ @line.intersection_at_z(4.0).z.should == 4.0
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ context "and is located in negative space" do
98
+ context "with a negative Z vector" do
99
+ before do
100
+ @line = Line.new(Vertex.new(-1.0, -1.0, -1.0), Vertex.new(-7.0, -7.0, -7.0))
101
+ end
102
+
103
+ it "should return a Point representing the intersection" do
104
+ @line.intersection_at_z(-4.0).x.should == -4.0
105
+ @line.intersection_at_z(-4.0).y.should == -4.0
106
+ @line.intersection_at_z(-4.0).z.should == -4.0
107
+ end
108
+ end
109
+
110
+ context "with a positive Z vector" do
111
+ before do
112
+ @line = Line.new(Vertex.new(-7.0, -7.0, -7.0), Vertex.new(-1.0, -1.0, -1.0))
113
+ end
114
+
115
+ it "should return a Point representing the intersection" do
116
+ @line.intersection_at_z(-4.0).x.should == -4.0
117
+ @line.intersection_at_z(-4.0).y.should == -4.0
118
+ @line.intersection_at_z(-4.0).z.should == -4.0
119
+ end
120
+ end
121
+ end
122
+
123
+ context "and spans both positive and negative space" do
124
+ context "with a positive Z vector" do
125
+ before do
126
+ @line = Line.new(Vertex.new(-1.0, 1.0, 1.0), Vertex.new(1.0, 1.0, -1.0))
127
+ end
128
+
129
+ it "should return a Point representing the intersection" do
130
+ @line.intersection_at_z(0).x.should == 0.0
131
+ @line.intersection_at_z(0).y.should == 1.0
132
+ @line.intersection_at_z(0).z.should == 0.0
133
+ end
134
+ end
135
+
136
+ context "with a negative Z vector" do
137
+ before do
138
+ @line = Line.new(Vertex.new(1.0, 1.0, 1.0), Vertex.new(-1.0, -1.0, -1.0))
139
+ end
140
+
141
+ it "should return a Point representing the intersection" do
142
+ @line.intersection_at_z(0).x.should == 0
143
+ @line.intersection_at_z(0).y.should == 0
144
+ @line.intersection_at_z(0).z.should == 0
145
+ end
146
+ end
147
+ end
148
+
149
+ context "for a line that lies on the target Z plane" do
150
+ before do
151
+ @line = Line.new(Vertex.new(0.0, 0.0, 3.0), Vertex.new(0.0, 6.0, 3.0))
152
+ end
153
+
154
+ it "should raise an error" do
155
+ lambda{
156
+ @line.intersection_at_z(3.0)
157
+ }.should raise_error
158
+ end
159
+ end
160
+
161
+ context "for a line that does not intersect the target Z plane" do
162
+ before do
163
+ @line = Line.new(Vertex.new(0.0, 0.0, 4.0), Vertex.new(0.0, 0.0, 6.0))
164
+ end
165
+
166
+ it "should return nil" do
167
+ @line.intersection_at_z(3.0).should be_nil
168
+ end
169
+ end
170
+ end
171
+
172
+ describe "==" do
173
+ it "should return true when the two lines are identical" do
174
+ (Line.new(Vertex.new(-1.0, -1.0, -1.0), Vertex.new(1.0, 1.0, 1.0)) == Line.new(Vertex.new(-1.0, -1.0, -1.0), Vertex.new(1.0, 1.0, 1.0))).should be_true
175
+ end
176
+
177
+ it "should not return true when the lines are not identical" do
178
+ (Line.new(Vertex.new(-1.0, -1.0, -1.1), Vertex.new(1.0, 1.0, 1.0)) == Line.new(Vertex.new(-1.0, -1.0, -1.0), Vertex.new(1.0, 1.0, 1.0))).should be_false
179
+ end
180
+ end
181
+
182
+ describe "#to_svg_path" do
183
+ it "should return a string containing an SVG path" do
184
+ line = Line.new(Vertex.new(0.0, 0.0, 0.0), Vertex.new(1.0, 1.0, 1.0))
185
+ expected_output = '<path d="M 0.0 0.0 L 1.0 1.0" fill="none" stroke="black" stroke-width="1" />'
186
+
187
+ line.to_svg_path.should == expected_output
188
+ end
189
+ end
190
+ end