@pie-element/graphing-solution-set 1.5.2-next.1 → 1.5.2-next.2
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/configure/lib/configure.js +398 -0
- package/configure/lib/configure.js.map +1 -0
- package/configure/lib/correct-response.js +596 -0
- package/configure/lib/correct-response.js.map +1 -0
- package/configure/lib/defaults.js +359 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/graphing-config.js +435 -0
- package/configure/lib/graphing-config.js.map +1 -0
- package/configure/lib/index.js +218 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/utils.js +754 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +1 -1
- package/controller/lib/defaults.js +71 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +423 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +273 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +1 -1
- package/lib/index.js +214 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +440 -0
- package/lib/main.js.map +1 -0
- package/lib/utils.js +604 -0
- package/lib/utils.js.map +1 -0
- package/package.json +3 -3
package/lib/utils.js
ADDED
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.removeInvalidAnswers = exports.pointInsidePolygon = exports.findSectionsInSolutionSet = exports.checkIfLinesAreAdded = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _excluded = ["angle"],
|
|
15
|
+
_excluded2 = ["type"];
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Check if a line is complete
|
|
19
|
+
* @param {Object} item - mark object
|
|
20
|
+
* */
|
|
21
|
+
var completeFromTo = function completeFromTo(item) {
|
|
22
|
+
return item && completeMark.point(item.from) && completeMark.point(item.to);
|
|
23
|
+
};
|
|
24
|
+
/*
|
|
25
|
+
* Check if a point is correct and complete
|
|
26
|
+
* @param {Object} point - point object
|
|
27
|
+
* */
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var completePoint = function completePoint(point) {
|
|
31
|
+
return point && Number.isFinite(point.x) && Number.isFinite(point.y);
|
|
32
|
+
};
|
|
33
|
+
/*
|
|
34
|
+
* Complete mark object for line and point
|
|
35
|
+
* */
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
var completeMark = {
|
|
39
|
+
line: completeFromTo,
|
|
40
|
+
point: completePoint
|
|
41
|
+
}; //////////////////////////////////////////////////////////////////////////////////
|
|
42
|
+
// BELOW FUNCTIONS ARE USED IN configure/src/utils as well
|
|
43
|
+
//////////////////////////////////////////////////////////////////////////////////
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Function to calculate the distance between two points
|
|
47
|
+
* @param {Object} a - point a
|
|
48
|
+
* @param {Object} b - point b
|
|
49
|
+
* */
|
|
50
|
+
|
|
51
|
+
var distance = function distance(a, b) {
|
|
52
|
+
return Number(Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)).toFixed(3));
|
|
53
|
+
};
|
|
54
|
+
/*
|
|
55
|
+
* Function to check if a point lies on edges of a polygon
|
|
56
|
+
* @param {Object} point - point object
|
|
57
|
+
* @param {Array} polygon - polygon points array
|
|
58
|
+
* */
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
var pointInPolygon = function pointInPolygon(point, polygon) {
|
|
62
|
+
var c = point;
|
|
63
|
+
var inside = false;
|
|
64
|
+
var clonePolygon = (0, _toConsumableArray2["default"])(polygon);
|
|
65
|
+
clonePolygon.push(polygon[0]);
|
|
66
|
+
|
|
67
|
+
for (var i = 0; i < clonePolygon.length - 1; i++) {
|
|
68
|
+
var a = clonePolygon[i];
|
|
69
|
+
var b = clonePolygon[i + 1]; // check if point is on the edge
|
|
70
|
+
|
|
71
|
+
if (distance(a, c) + distance(c, b) === distance(a, b)) {
|
|
72
|
+
inside = true;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return inside;
|
|
78
|
+
};
|
|
79
|
+
/*
|
|
80
|
+
* Function to get the intersection point of two lines
|
|
81
|
+
* @param {Number} x1 - x coordinate of point 1 of line 1
|
|
82
|
+
* @param {Number} y1 - y coordinate of point 1 of line 1
|
|
83
|
+
* @param {Number} x2 - x coordinate of point 2 of line 1
|
|
84
|
+
* @param {Number} y2 - y coordinate of point 2 of line 1
|
|
85
|
+
* @param {Number} x3 - x coordinate of point 1 of line 2
|
|
86
|
+
* @param {Number} y3 - y coordinate of point 1 of line 2
|
|
87
|
+
* @param {Number} x4 - x coordinate of point 2 of line 2
|
|
88
|
+
* @param {Number} y4 - y coordinate of point 2 of line 2
|
|
89
|
+
* */
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var lineIntersect = function lineIntersect(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
93
|
+
var ua,
|
|
94
|
+
denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
|
|
95
|
+
|
|
96
|
+
if (denominator === 0) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator;
|
|
101
|
+
return {
|
|
102
|
+
x: Number((x1 + ua * (x2 - x1)).toFixed(3)),
|
|
103
|
+
y: Number((y1 + ua * (y2 - y1)).toFixed(3))
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/*
|
|
107
|
+
* Check if a point is inside the graph
|
|
108
|
+
* @param {Object} point - point object
|
|
109
|
+
* @param {Object} domain - domain object
|
|
110
|
+
* @param {Object} range - range object
|
|
111
|
+
* */
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
var isPointInsideGraph = function isPointInsideGraph(point, domain, range) {
|
|
115
|
+
return point.x > domain.min && point.x < domain.max && point.y > range.min && point.y < range.max;
|
|
116
|
+
};
|
|
117
|
+
/*
|
|
118
|
+
* Check if a point is on or inside the graph
|
|
119
|
+
* @param {Object} point - point object
|
|
120
|
+
* @param {Object} domain - domain object
|
|
121
|
+
* @param {Object} range - range object
|
|
122
|
+
* */
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
var isPointOnOrInsideGraph = function isPointOnOrInsideGraph(point, domain, range) {
|
|
126
|
+
return point.x >= domain.min && point.x <= domain.max && point.y >= range.min && point.y <= range.max;
|
|
127
|
+
};
|
|
128
|
+
/*
|
|
129
|
+
* Find the intersection point of a mark with the graph
|
|
130
|
+
* @param {Object} mark - mark object
|
|
131
|
+
* @param {Object} domain - domain object
|
|
132
|
+
* @param {Object} range - range object
|
|
133
|
+
* */
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
var findIntersectionPointForMark = function findIntersectionPointForMark(mark, domain, range) {
|
|
137
|
+
var intersectionPoint = [];
|
|
138
|
+
var tempData = [[domain.max, range.max, domain.max, range.min], [domain.min, range.max, domain.min, range.min], [domain.min, range.max, domain.max, range.max], [domain.min, range.min, domain.max, range.min]];
|
|
139
|
+
|
|
140
|
+
for (var i = 0; i < tempData.length; i++) {
|
|
141
|
+
var intersection = lineIntersect(mark.from.x, mark.from.y, mark.to.x, mark.to.y, tempData[i][0], tempData[i][1], tempData[i][2], tempData[i][3]);
|
|
142
|
+
|
|
143
|
+
if (intersection && isPointOnOrInsideGraph(intersection, domain, range)) {
|
|
144
|
+
intersectionPoint.push(intersection);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return intersectionPoint;
|
|
149
|
+
};
|
|
150
|
+
/*
|
|
151
|
+
* Sort points in clockwise direction for a polygon
|
|
152
|
+
* @param {Array} points - points array
|
|
153
|
+
* */
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
var sortPointsClockWise = function sortPointsClockWise(points) {
|
|
157
|
+
// Find min max to get center and Sort from top to bottom
|
|
158
|
+
points.sort(function (a, b) {
|
|
159
|
+
return a.y - b.y;
|
|
160
|
+
}); // Get center y
|
|
161
|
+
|
|
162
|
+
var cy = (points[0].y + points[points.length - 1].y) / 2; // Sort from right to left
|
|
163
|
+
|
|
164
|
+
points.sort(function (a, b) {
|
|
165
|
+
return b.x - a.x;
|
|
166
|
+
}); // Get center x
|
|
167
|
+
|
|
168
|
+
var cx = (points[0].x + points[points.length - 1].x) / 2; // Center point
|
|
169
|
+
|
|
170
|
+
var center = {
|
|
171
|
+
x: cx,
|
|
172
|
+
y: cy
|
|
173
|
+
}; // As the points are sorted from right to left the first point is the rightmost Starting angle used to reference other angles
|
|
174
|
+
|
|
175
|
+
var startAng;
|
|
176
|
+
points.forEach(function (point) {
|
|
177
|
+
var ang = Math.atan2(point.y - center.y, point.x - center.x);
|
|
178
|
+
|
|
179
|
+
if (!startAng) {
|
|
180
|
+
startAng = ang;
|
|
181
|
+
} else {
|
|
182
|
+
if (ang < startAng) {
|
|
183
|
+
// ensure that all points are clockwise of the start point
|
|
184
|
+
ang += Math.PI * 2;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
point.angle = ang; // add the angle to the point
|
|
189
|
+
}); // first sort clockwise
|
|
190
|
+
|
|
191
|
+
points.sort(function (a, b) {
|
|
192
|
+
return a.angle - b.angle;
|
|
193
|
+
}); // then reverse the order
|
|
194
|
+
|
|
195
|
+
var ccwPoints = points.reverse(); // move the last point back to the start
|
|
196
|
+
|
|
197
|
+
ccwPoints.unshift(ccwPoints.pop());
|
|
198
|
+
return ccwPoints.map(function (_ref) {
|
|
199
|
+
var angle = _ref.angle,
|
|
200
|
+
attr = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
201
|
+
return attr;
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
/*
|
|
205
|
+
* Function to calculate the dot product of two vectors
|
|
206
|
+
* @param {Object} v1 - point 1
|
|
207
|
+
* @param {Object} v2 - point 2
|
|
208
|
+
* */
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
var dotProduct = function dotProduct(v1, v2) {
|
|
212
|
+
return v1.x * v2.x + v1.y * v2.y;
|
|
213
|
+
};
|
|
214
|
+
/*
|
|
215
|
+
* Function to calculate the magnitude of a vector
|
|
216
|
+
* @param {Object} v - point object
|
|
217
|
+
* */
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
var magnitude = function magnitude(v) {
|
|
221
|
+
return Math.sqrt(v.x * v.x + v.y * v.y);
|
|
222
|
+
};
|
|
223
|
+
/*
|
|
224
|
+
* Function to calculate the angle between two vectors in radians
|
|
225
|
+
* @param {Object} v1 - point 1
|
|
226
|
+
* @param {Object} v2 - point 2
|
|
227
|
+
* */
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
var angleBetweenVectors = function angleBetweenVectors(v1, v2) {
|
|
231
|
+
var dot = dotProduct(v1, v2);
|
|
232
|
+
var magV1 = magnitude(v1);
|
|
233
|
+
var magV2 = magnitude(v2); // Ensure the dot product is within the domain of the acos function
|
|
234
|
+
|
|
235
|
+
return Math.acos(dot / (magV1 * magV2));
|
|
236
|
+
};
|
|
237
|
+
/*
|
|
238
|
+
* Function to check if a point lies between the angle formed by two lines
|
|
239
|
+
* @param {Object} commonPoint - common point of the two lines
|
|
240
|
+
* @param {Object} point1 - point 1 of cone
|
|
241
|
+
* @param {Object} point2 - point 2 of cone
|
|
242
|
+
* @param {Object} testPoint - point to be tested
|
|
243
|
+
* */
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
var pointInAngle = function pointInAngle(commonPoint, point1, point2, testPoint) {
|
|
247
|
+
var vector1 = {
|
|
248
|
+
x: point1.x - commonPoint.x,
|
|
249
|
+
y: point1.y - commonPoint.y
|
|
250
|
+
};
|
|
251
|
+
var vector2 = {
|
|
252
|
+
x: point2.x - commonPoint.x,
|
|
253
|
+
y: point2.y - commonPoint.y
|
|
254
|
+
};
|
|
255
|
+
var testVector = {
|
|
256
|
+
x: testPoint.x - commonPoint.x,
|
|
257
|
+
y: testPoint.y - commonPoint.y
|
|
258
|
+
};
|
|
259
|
+
var angle1 = angleBetweenVectors(vector1, testVector);
|
|
260
|
+
var angle2 = angleBetweenVectors(vector2, testVector);
|
|
261
|
+
var angleSum = angle1 + angle2; // Check if the sum of angles is approximately equal to the angle between the two lines
|
|
262
|
+
// You may need to adjust the tolerance (e.g., 0.0001) based on your specific requirements
|
|
263
|
+
|
|
264
|
+
var tolerance = 0.0001;
|
|
265
|
+
return Math.abs(angleSum - angleBetweenVectors(vector1, vector2)) < tolerance;
|
|
266
|
+
};
|
|
267
|
+
/*
|
|
268
|
+
* Function to remove duplicate points from an array
|
|
269
|
+
* @param {Array} array - array of points
|
|
270
|
+
* */
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
var removeDuplicatesFromArray = function removeDuplicatesFromArray(array) {
|
|
274
|
+
return array.filter(function (obj, index) {
|
|
275
|
+
return index === array.findIndex(function (o) {
|
|
276
|
+
return obj.x === o.x && obj.y === o.y;
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
/*
|
|
281
|
+
* Function to remove duplicate points and filter sections
|
|
282
|
+
* @param {Array} sections - array of sections
|
|
283
|
+
* */
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
var removeDuplicateAndFilterSections = function removeDuplicateAndFilterSections(sections) {
|
|
287
|
+
var _loop = function _loop(i) {
|
|
288
|
+
sections[i] = sections[i].filter(function (obj, index) {
|
|
289
|
+
return index === sections[i].findIndex(function (o) {
|
|
290
|
+
return obj.x === o.x && obj.y === o.y;
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
//removing duplicate points.
|
|
296
|
+
for (var i = 0; i < sections.length; i++) {
|
|
297
|
+
_loop(i);
|
|
298
|
+
} //removing arrays with two points
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
sections = sections.filter(function (section) {
|
|
302
|
+
return section.length > 2;
|
|
303
|
+
}); //sorting the points in clockwise direction
|
|
304
|
+
|
|
305
|
+
for (var _i = 0; _i < sections.length; _i++) {
|
|
306
|
+
sections[_i] = sortPointsClockWise(sections[_i]);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return sections;
|
|
310
|
+
};
|
|
311
|
+
/*
|
|
312
|
+
* Function to find sections in solution set for one line
|
|
313
|
+
* @param {Array} intersectionPoint - intersection point
|
|
314
|
+
* @param {Object} domain - domain object
|
|
315
|
+
* @param {Object} range - range object
|
|
316
|
+
* */
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
var findSectionsInSolutionSetForOneLine = function findSectionsInSolutionSetForOneLine(intersectionPoint, domain, range) {
|
|
320
|
+
var sections = [];
|
|
321
|
+
sections.push([].concat(intersectionPoint));
|
|
322
|
+
sections.push([].concat(intersectionPoint));
|
|
323
|
+
|
|
324
|
+
if (intersectionPoint[0].x === domain.max && intersectionPoint[1].y === range.max || intersectionPoint[1].x === domain.max && intersectionPoint[0].y === range.max) {
|
|
325
|
+
sections[0].push({
|
|
326
|
+
x: domain.max,
|
|
327
|
+
y: range.max
|
|
328
|
+
});
|
|
329
|
+
sections[1].push({
|
|
330
|
+
x: domain.min,
|
|
331
|
+
y: range.max
|
|
332
|
+
}, {
|
|
333
|
+
x: domain.min,
|
|
334
|
+
y: range.min
|
|
335
|
+
}, {
|
|
336
|
+
x: domain.max,
|
|
337
|
+
y: range.min
|
|
338
|
+
});
|
|
339
|
+
} else if (intersectionPoint[0].x === domain.min && intersectionPoint[1].y === range.max || intersectionPoint[1].x === domain.min && intersectionPoint[0].y === range.max) {
|
|
340
|
+
sections[0].push({
|
|
341
|
+
x: domain.min,
|
|
342
|
+
y: range.max
|
|
343
|
+
});
|
|
344
|
+
sections[1].push({
|
|
345
|
+
x: domain.max,
|
|
346
|
+
y: range.max
|
|
347
|
+
}, {
|
|
348
|
+
x: domain.max,
|
|
349
|
+
y: range.min
|
|
350
|
+
}, {
|
|
351
|
+
x: domain.min,
|
|
352
|
+
y: range.min
|
|
353
|
+
});
|
|
354
|
+
} else if (intersectionPoint[0].x === domain.min && intersectionPoint[1].y === range.min || intersectionPoint[1].x === domain.min && intersectionPoint[0].y === range.min) {
|
|
355
|
+
sections[0].push({
|
|
356
|
+
x: domain.min,
|
|
357
|
+
y: range.min
|
|
358
|
+
});
|
|
359
|
+
sections[1].push({
|
|
360
|
+
x: domain.max,
|
|
361
|
+
y: range.min
|
|
362
|
+
}, {
|
|
363
|
+
x: domain.max,
|
|
364
|
+
y: range.max
|
|
365
|
+
}, {
|
|
366
|
+
x: domain.min,
|
|
367
|
+
y: range.max
|
|
368
|
+
});
|
|
369
|
+
} else if (intersectionPoint[0].x === domain.max && intersectionPoint[1].y === range.min || intersectionPoint[1].x === domain.max && intersectionPoint[0].y === range.min) {
|
|
370
|
+
sections[0].push({
|
|
371
|
+
x: domain.max,
|
|
372
|
+
y: range.min
|
|
373
|
+
});
|
|
374
|
+
sections[1].push({
|
|
375
|
+
x: domain.min,
|
|
376
|
+
y: range.min
|
|
377
|
+
}, {
|
|
378
|
+
x: domain.min,
|
|
379
|
+
y: range.max
|
|
380
|
+
}, {
|
|
381
|
+
x: domain.max,
|
|
382
|
+
y: range.max
|
|
383
|
+
});
|
|
384
|
+
} else if (intersectionPoint[0].x === domain.min && intersectionPoint[1].x === domain.max || intersectionPoint[0].x === domain.max && intersectionPoint[1].x === domain.min) {
|
|
385
|
+
sections[0].push({
|
|
386
|
+
x: domain.min,
|
|
387
|
+
y: range.max
|
|
388
|
+
}, {
|
|
389
|
+
x: domain.max,
|
|
390
|
+
y: range.max
|
|
391
|
+
});
|
|
392
|
+
sections[1].push({
|
|
393
|
+
x: domain.min,
|
|
394
|
+
y: range.min
|
|
395
|
+
}, {
|
|
396
|
+
x: domain.max,
|
|
397
|
+
y: range.min
|
|
398
|
+
});
|
|
399
|
+
} else if (intersectionPoint[0].y === range.min && intersectionPoint[1].y === range.max || intersectionPoint[0].y === range.max && intersectionPoint[1].y === range.min) {
|
|
400
|
+
sections[0].push({
|
|
401
|
+
x: domain.min,
|
|
402
|
+
y: range.min
|
|
403
|
+
}, {
|
|
404
|
+
x: domain.min,
|
|
405
|
+
y: range.max
|
|
406
|
+
});
|
|
407
|
+
sections[1].push({
|
|
408
|
+
x: domain.max,
|
|
409
|
+
y: range.min
|
|
410
|
+
}, {
|
|
411
|
+
x: domain.max,
|
|
412
|
+
y: range.max
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return removeDuplicateAndFilterSections(sections);
|
|
417
|
+
};
|
|
418
|
+
/*
|
|
419
|
+
* Function to find sections in solution set for two lines
|
|
420
|
+
* @param {Object} gssLineData - graphing solution set line data
|
|
421
|
+
* @param {Array} answers - answers array
|
|
422
|
+
* @param {Object} domain - domain object
|
|
423
|
+
* @param {Object} range - range object
|
|
424
|
+
* */
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
var findSectionsInSolutionSetForTwoLines = function findSectionsInSolutionSetForTwoLines(gssLineData, answers, domain, range) {
|
|
428
|
+
var mark1 = answers[0];
|
|
429
|
+
var mark2 = answers[1];
|
|
430
|
+
var cornerPoints = [{
|
|
431
|
+
x: domain.min,
|
|
432
|
+
y: range.min
|
|
433
|
+
}, {
|
|
434
|
+
x: domain.min,
|
|
435
|
+
y: range.max
|
|
436
|
+
}, {
|
|
437
|
+
x: domain.max,
|
|
438
|
+
y: range.min
|
|
439
|
+
}, {
|
|
440
|
+
x: domain.max,
|
|
441
|
+
y: range.max
|
|
442
|
+
}];
|
|
443
|
+
var intersectPoint = lineIntersect(mark1.from.x, mark1.from.y, mark1.to.x, mark1.to.y, mark2.from.x, mark2.from.y, mark2.to.x, mark2.to.y);
|
|
444
|
+
var sections = [];
|
|
445
|
+
var intersectionPoint1 = findIntersectionPointForMark(mark1, domain, range);
|
|
446
|
+
intersectionPoint1 = removeDuplicatesFromArray(intersectionPoint1);
|
|
447
|
+
var intersectionPoint2 = findIntersectionPointForMark(mark2, domain, range);
|
|
448
|
+
intersectionPoint2 = removeDuplicatesFromArray(intersectionPoint2);
|
|
449
|
+
|
|
450
|
+
if (intersectPoint && isPointInsideGraph(intersectPoint, domain, range)) {
|
|
451
|
+
for (var i = 0; i < intersectionPoint1.length; i++) {
|
|
452
|
+
for (var j = 0; j < intersectionPoint2.length; j++) {
|
|
453
|
+
var bucket = [];
|
|
454
|
+
var newCornerPoints = [];
|
|
455
|
+
bucket.push(intersectPoint);
|
|
456
|
+
bucket.push(intersectionPoint1[i]);
|
|
457
|
+
bucket.push(intersectionPoint2[j]);
|
|
458
|
+
|
|
459
|
+
for (var k = 0; k < cornerPoints.length; k++) {
|
|
460
|
+
if (pointInAngle(intersectPoint, intersectionPoint1[i], intersectionPoint2[j], cornerPoints[k])) {
|
|
461
|
+
bucket.push(cornerPoints[k]);
|
|
462
|
+
} else {
|
|
463
|
+
newCornerPoints.push(cornerPoints[k]);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
cornerPoints = newCornerPoints;
|
|
468
|
+
sections.push(bucket);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
var sections1 = findSectionsInSolutionSetForOneLine(intersectionPoint1, domain, range);
|
|
473
|
+
var sections2 = findSectionsInSolutionSetForOneLine(intersectionPoint2, domain, range);
|
|
474
|
+
|
|
475
|
+
for (var _i2 = 0; _i2 < sections1.length; _i2++) {
|
|
476
|
+
if (!(pointInPolygon(intersectionPoint2[0], sections1[_i2]) && pointInPolygon(intersectionPoint2[1], sections1[_i2]))) {
|
|
477
|
+
sections.push(sections1[_i2]);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
for (var _i3 = 0; _i3 < sections2.length; _i3++) {
|
|
482
|
+
if (!(pointInPolygon(intersectionPoint1[0], sections2[_i3]) && pointInPolygon(intersectionPoint1[1], sections2[_i3]))) {
|
|
483
|
+
sections.push(sections2[_i3]);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
var _loop2 = function _loop2(_i4) {
|
|
488
|
+
cornerPoints = cornerPoints.filter(function (o1) {
|
|
489
|
+
return !sections[_i4].some(function (o2) {
|
|
490
|
+
return o1.x === o2.x && o1.y === o2.y;
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
for (var _i4 = 0; _i4 < sections.length; _i4++) {
|
|
496
|
+
_loop2(_i4);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
var sections3 = cornerPoints.concat(intersectionPoint1, intersectionPoint2);
|
|
500
|
+
sections.push(sections3);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return removeDuplicateAndFilterSections(sections);
|
|
504
|
+
};
|
|
505
|
+
/*
|
|
506
|
+
* Function to find sections in solution set
|
|
507
|
+
* @param {Object} gssLineData - graphing solution set line data
|
|
508
|
+
* @param {Array} answers - answers array
|
|
509
|
+
* @param {Object} domain - domain object
|
|
510
|
+
* @param {Object} range - range object
|
|
511
|
+
* */
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
var findSectionsInSolutionSet = function findSectionsInSolutionSet(gssLineData, answers, domain, range) {
|
|
515
|
+
if (gssLineData.numberOfLines === 1) {
|
|
516
|
+
var intersectionPoint = findIntersectionPointForMark(answers[0], domain, range);
|
|
517
|
+
gssLineData.sections = findSectionsInSolutionSetForOneLine(intersectionPoint, domain, range);
|
|
518
|
+
} else {
|
|
519
|
+
gssLineData.sections = findSectionsInSolutionSetForTwoLines(gssLineData, answers, domain, range);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return gssLineData;
|
|
523
|
+
};
|
|
524
|
+
/*
|
|
525
|
+
* Function to check if a point is inside a polygon
|
|
526
|
+
* @param {Object} point - point to be checked
|
|
527
|
+
* @param {Array} polygon - polygon points array
|
|
528
|
+
* */
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
exports.findSectionsInSolutionSet = findSectionsInSolutionSet;
|
|
532
|
+
|
|
533
|
+
var pointInsidePolygon = function pointInsidePolygon(point, polygon) {
|
|
534
|
+
var num_vertices = polygon.length;
|
|
535
|
+
var x = point.x;
|
|
536
|
+
var y = point.y;
|
|
537
|
+
var inside = false;
|
|
538
|
+
var p1 = polygon[0];
|
|
539
|
+
var p2;
|
|
540
|
+
|
|
541
|
+
for (var i = 1; i <= num_vertices; i++) {
|
|
542
|
+
p2 = polygon[i % num_vertices];
|
|
543
|
+
|
|
544
|
+
if (y > Math.min(p1.y, p2.y)) {
|
|
545
|
+
if (y <= Math.max(p1.y, p2.y)) {
|
|
546
|
+
if (x <= Math.max(p1.x, p2.x)) {
|
|
547
|
+
var x_intersection = (y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;
|
|
548
|
+
|
|
549
|
+
if (p1.x === p2.x || x <= x_intersection) {
|
|
550
|
+
inside = !inside;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
p1 = p2;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return inside;
|
|
560
|
+
};
|
|
561
|
+
/*
|
|
562
|
+
* Function to check if lines are added in the graph
|
|
563
|
+
* @param {Object} gssLineData - graphing solution set line data
|
|
564
|
+
* @param {Array} answer - answer array
|
|
565
|
+
* */
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
exports.pointInsidePolygon = pointInsidePolygon;
|
|
569
|
+
|
|
570
|
+
var checkIfLinesAreAdded = function checkIfLinesAreAdded(gssLineData, answer) {
|
|
571
|
+
if (answer.length === 0) {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
if (gssLineData.numberOfLines === 1) {
|
|
576
|
+
if (answer.length === 1) {
|
|
577
|
+
return !answer[0].building;
|
|
578
|
+
}
|
|
579
|
+
} else {
|
|
580
|
+
if (answer.length !== 2) {
|
|
581
|
+
return false;
|
|
582
|
+
} else {
|
|
583
|
+
return !answer[1].building;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
/*
|
|
588
|
+
* Function to remove invalid answers
|
|
589
|
+
* @param {Array} answers - answers array
|
|
590
|
+
* */
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
exports.checkIfLinesAreAdded = checkIfLinesAreAdded;
|
|
594
|
+
|
|
595
|
+
var removeInvalidAnswers = function removeInvalidAnswers(answers) {
|
|
596
|
+
return answers ? (answers || []).filter(function (_ref2) {
|
|
597
|
+
var type = _ref2.type,
|
|
598
|
+
answer = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2);
|
|
599
|
+
return completeMark[type] ? completeMark[type](answer) : false;
|
|
600
|
+
}) : [];
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
exports.removeInvalidAnswers = removeInvalidAnswers;
|
|
604
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["completeFromTo","item","completeMark","point","from","to","completePoint","Number","isFinite","x","y","line","distance","a","b","Math","sqrt","toFixed","pointInPolygon","polygon","c","inside","clonePolygon","push","i","length","lineIntersect","x1","y1","x2","y2","x3","y3","x4","y4","ua","denominator","isPointInsideGraph","domain","range","min","max","isPointOnOrInsideGraph","findIntersectionPointForMark","mark","intersectionPoint","tempData","intersection","sortPointsClockWise","points","sort","cy","cx","center","startAng","forEach","ang","atan2","PI","angle","ccwPoints","reverse","unshift","pop","map","attr","dotProduct","v1","v2","magnitude","v","angleBetweenVectors","dot","magV1","magV2","acos","pointInAngle","commonPoint","point1","point2","testPoint","vector1","vector2","testVector","angle1","angle2","angleSum","tolerance","abs","removeDuplicatesFromArray","array","filter","obj","index","findIndex","o","removeDuplicateAndFilterSections","sections","section","findSectionsInSolutionSetForOneLine","concat","findSectionsInSolutionSetForTwoLines","gssLineData","answers","mark1","mark2","cornerPoints","intersectPoint","intersectionPoint1","intersectionPoint2","j","bucket","newCornerPoints","k","sections1","sections2","o1","some","o2","sections3","findSectionsInSolutionSet","numberOfLines","pointInsidePolygon","num_vertices","p1","p2","x_intersection","checkIfLinesAreAdded","answer","building","removeInvalidAnswers","type"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD;AAAA,SAAUA,IAAI,IAAIC,YAAY,CAACC,KAAb,CAAmBF,IAAI,CAACG,IAAxB,CAAR,IAAyCF,YAAY,CAACC,KAAb,CAAmBF,IAAI,CAACI,EAAxB,CAAnD;AAAA,CAAvB;AAEA;AACA;AACA;AACA;;;AACA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACH,KAAD;AAAA,SAAWA,KAAK,IAAII,MAAM,CAACC,QAAP,CAAgBL,KAAK,CAACM,CAAtB,CAAT,IAAqCF,MAAM,CAACC,QAAP,CAAgBL,KAAK,CAACO,CAAtB,CAAhD;AAAA,CAAtB;AAEA;AACA;AACA;;;AACA,IAAMR,YAAY,GAAG;AACnBS,EAAAA,IAAI,EAAEX,cADa;AAEnBG,EAAAA,KAAK,EAAEG;AAFY,CAArB,C,CAKA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA,IAAMM,QAAQ,GAAG,SAAXA,QAAW,CAACC,CAAD,EAAIC,CAAJ,EAAU;AACzB,SAAOP,MAAM,CAACQ,IAAI,CAACC,IAAL,CAAU,SAACH,CAAC,CAACJ,CAAF,GAAMK,CAAC,CAACL,CAAT,EAAe,CAAf,aAAoBI,CAAC,CAACH,CAAF,GAAMI,CAAC,CAACJ,CAA5B,EAAkC,CAAlC,C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P;AACD,CAtBM;AAwBP;AACA;AACA;AACA;AACA;;;;;AACO,IAAM0G,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACzB,WAAD,EAAc0B,MAAd,EAAyB;AAC3D,MAAIA,MAAM,CAACvG,MAAP,KAAkB,CAAtB,EAAyB;AACvB,WAAO,KAAP;AACD;;AACD,MAAI6E,WAAW,CAACmB,aAAZ,KAA8B,CAAlC,EAAqC;AACnC,QAAIO,MAAM,CAACvG,MAAP,KAAkB,CAAtB,EAAyB;AACvB,aAAO,CAACuG,MAAM,CAAC,CAAD,CAAN,CAAUC,QAAlB;AACD;AACF,GAJD,MAIO;AACL,QAAID,MAAM,CAACvG,MAAP,KAAkB,CAAtB,EAAyB;AACvB,aAAO,KAAP;AACD,KAFD,MAEO;AACL,aAAO,CAACuG,MAAM,CAAC,CAAD,CAAN,CAAUC,QAAlB;AACD;AACF;AACF,CAfM;AAiBP;AACA;AACA;AACA;;;;;AACO,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAAC3B,OAAD;AAAA,SAClCA,OAAO,GACH,CAACA,OAAO,IAAI,EAAZ,EAAgBZ,MAAhB,CAAuB;AAAA,QAAGwC,IAAH,SAAGA,IAAH;AAAA,QAAYH,MAAZ;AAAA,WAA0B9H,YAAY,CAACiI,IAAD,CAAZ,GAAqBjI,YAAY,CAACiI,IAAD,CAAZ,CAAmBH,MAAnB,CAArB,GAAkD,KAA5E;AAAA,GAAvB,CADG,GAEH,EAH8B;AAAA,CAA7B","sourcesContent":["/*\n * Check if a line is complete\n * @param {Object} item - mark object\n * */\nconst completeFromTo = (item) => item && completeMark.point(item.from) && completeMark.point(item.to);\n\n/*\n * Check if a point is correct and complete\n * @param {Object} point - point object\n * */\nconst completePoint = (point) => point && Number.isFinite(point.x) && Number.isFinite(point.y);\n\n/*\n * Complete mark object for line and point\n * */\nconst completeMark = {\n line: completeFromTo,\n point: completePoint,\n};\n\n//////////////////////////////////////////////////////////////////////////////////\n// BELOW FUNCTIONS ARE USED IN configure/src/utils as well\n//////////////////////////////////////////////////////////////////////////////////\n\n/*\n * Function to calculate the distance between two points\n * @param {Object} a - point a\n * @param {Object} b - point b\n * */\nconst distance = (a, b) => {\n return Number(Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2).toFixed(3));\n};\n\n/*\n * Function to check if a point lies on edges of a polygon\n * @param {Object} point - point object\n * @param {Array} polygon - polygon points array\n * */\nconst pointInPolygon = (point, polygon) => {\n let c = point;\n let inside = false;\n let clonePolygon = [...polygon];\n clonePolygon.push(polygon[0]);\n for (let i = 0; i < clonePolygon.length - 1; i++) {\n let a = clonePolygon[i];\n let b = clonePolygon[i + 1];\n // check if point is on the edge\n if (distance(a, c) + distance(c, b) === distance(a, b)) {\n inside = true;\n break;\n }\n }\n return inside;\n};\n\n/*\n * Function to get the intersection point of two lines\n * @param {Number} x1 - x coordinate of point 1 of line 1\n * @param {Number} y1 - y coordinate of point 1 of line 1\n * @param {Number} x2 - x coordinate of point 2 of line 1\n * @param {Number} y2 - y coordinate of point 2 of line 1\n * @param {Number} x3 - x coordinate of point 1 of line 2\n * @param {Number} y3 - y coordinate of point 1 of line 2\n * @param {Number} x4 - x coordinate of point 2 of line 2\n * @param {Number} y4 - y coordinate of point 2 of line 2\n * */\nconst lineIntersect = (x1, y1, x2, y2, x3, y3, x4, y4) => {\n let ua,\n denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);\n if (denominator === 0) {\n return null;\n }\n ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator;\n return {\n x: Number((x1 + ua * (x2 - x1)).toFixed(3)),\n y: Number((y1 + ua * (y2 - y1)).toFixed(3)),\n };\n};\n\n/*\n * Check if a point is inside the graph\n * @param {Object} point - point object\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst isPointInsideGraph = (point, domain, range) => {\n return point.x > domain.min && point.x < domain.max && point.y > range.min && point.y < range.max;\n};\n\n/*\n * Check if a point is on or inside the graph\n * @param {Object} point - point object\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst isPointOnOrInsideGraph = (point, domain, range) => {\n return point.x >= domain.min && point.x <= domain.max && point.y >= range.min && point.y <= range.max;\n};\n\n/*\n * Find the intersection point of a mark with the graph\n * @param {Object} mark - mark object\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst findIntersectionPointForMark = (mark, domain, range) => {\n let intersectionPoint = [];\n let tempData = [\n [domain.max, range.max, domain.max, range.min],\n [domain.min, range.max, domain.min, range.min],\n [domain.min, range.max, domain.max, range.max],\n [domain.min, range.min, domain.max, range.min],\n ];\n for (let i = 0; i < tempData.length; i++) {\n let intersection = lineIntersect(\n mark.from.x,\n mark.from.y,\n mark.to.x,\n mark.to.y,\n tempData[i][0],\n tempData[i][1],\n tempData[i][2],\n tempData[i][3],\n );\n if (intersection && isPointOnOrInsideGraph(intersection, domain, range)) {\n intersectionPoint.push(intersection);\n }\n }\n return intersectionPoint;\n};\n\n/*\n * Sort points in clockwise direction for a polygon\n * @param {Array} points - points array\n * */\nconst sortPointsClockWise = (points) => {\n // Find min max to get center and Sort from top to bottom\n points.sort((a, b) => a.y - b.y);\n // Get center y\n const cy = (points[0].y + points[points.length - 1].y) / 2;\n // Sort from right to left\n points.sort((a, b) => b.x - a.x);\n // Get center x\n const cx = (points[0].x + points[points.length - 1].x) / 2;\n // Center point\n const center = { x: cx, y: cy };\n // As the points are sorted from right to left the first point is the rightmost Starting angle used to reference other angles\n let startAng;\n points.forEach((point) => {\n let ang = Math.atan2(point.y - center.y, point.x - center.x);\n if (!startAng) {\n startAng = ang;\n } else {\n if (ang < startAng) {\n // ensure that all points are clockwise of the start point\n ang += Math.PI * 2;\n }\n }\n point.angle = ang; // add the angle to the point\n });\n // first sort clockwise\n points.sort((a, b) => a.angle - b.angle);\n // then reverse the order\n const ccwPoints = points.reverse();\n // move the last point back to the start\n ccwPoints.unshift(ccwPoints.pop());\n return ccwPoints.map(({ angle, ...attr }) => attr);\n};\n\n/*\n * Function to calculate the dot product of two vectors\n * @param {Object} v1 - point 1\n * @param {Object} v2 - point 2\n * */\nconst dotProduct = (v1, v2) => {\n return v1.x * v2.x + v1.y * v2.y;\n};\n\n/*\n * Function to calculate the magnitude of a vector\n * @param {Object} v - point object\n * */\nconst magnitude = (v) => {\n return Math.sqrt(v.x * v.x + v.y * v.y);\n};\n\n/*\n * Function to calculate the angle between two vectors in radians\n * @param {Object} v1 - point 1\n * @param {Object} v2 - point 2\n * */\nconst angleBetweenVectors = (v1, v2) => {\n const dot = dotProduct(v1, v2);\n const magV1 = magnitude(v1);\n const magV2 = magnitude(v2);\n // Ensure the dot product is within the domain of the acos function\n return Math.acos(dot / (magV1 * magV2));\n};\n\n/*\n * Function to check if a point lies between the angle formed by two lines\n * @param {Object} commonPoint - common point of the two lines\n * @param {Object} point1 - point 1 of cone\n * @param {Object} point2 - point 2 of cone\n * @param {Object} testPoint - point to be tested\n * */\nconst pointInAngle = (commonPoint, point1, point2, testPoint) => {\n const vector1 = { x: point1.x - commonPoint.x, y: point1.y - commonPoint.y };\n const vector2 = { x: point2.x - commonPoint.x, y: point2.y - commonPoint.y };\n const testVector = { x: testPoint.x - commonPoint.x, y: testPoint.y - commonPoint.y };\n const angle1 = angleBetweenVectors(vector1, testVector);\n const angle2 = angleBetweenVectors(vector2, testVector);\n const angleSum = angle1 + angle2;\n // Check if the sum of angles is approximately equal to the angle between the two lines\n // You may need to adjust the tolerance (e.g., 0.0001) based on your specific requirements\n const tolerance = 0.0001;\n return Math.abs(angleSum - angleBetweenVectors(vector1, vector2)) < tolerance;\n};\n\n/*\n * Function to remove duplicate points from an array\n * @param {Array} array - array of points\n * */\nconst removeDuplicatesFromArray = (array) => {\n return array.filter((obj, index) => {\n return index === array.findIndex((o) => obj.x === o.x && obj.y === o.y);\n });\n};\n\n/*\n * Function to remove duplicate points and filter sections\n * @param {Array} sections - array of sections\n * */\nconst removeDuplicateAndFilterSections = (sections) => {\n //removing duplicate points.\n for (let i = 0; i < sections.length; i++) {\n sections[i] = sections[i].filter((obj, index) => {\n return index === sections[i].findIndex((o) => obj.x === o.x && obj.y === o.y);\n });\n }\n //removing arrays with two points\n sections = sections.filter((section) => section.length > 2);\n //sorting the points in clockwise direction\n for (let i = 0; i < sections.length; i++) {\n sections[i] = sortPointsClockWise(sections[i]);\n }\n return sections;\n};\n\n/*\n * Function to find sections in solution set for one line\n * @param {Array} intersectionPoint - intersection point\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst findSectionsInSolutionSetForOneLine = (intersectionPoint, domain, range) => {\n let sections = [];\n sections.push([].concat(intersectionPoint));\n sections.push([].concat(intersectionPoint));\n if (\n (intersectionPoint[0].x === domain.max && intersectionPoint[1].y === range.max) ||\n (intersectionPoint[1].x === domain.max && intersectionPoint[0].y === range.max)\n ) {\n sections[0].push({ x: domain.max, y: range.max });\n sections[1].push({ x: domain.min, y: range.max }, { x: domain.min, y: range.min }, { x: domain.max, y: range.min });\n } else if (\n (intersectionPoint[0].x === domain.min && intersectionPoint[1].y === range.max) ||\n (intersectionPoint[1].x === domain.min && intersectionPoint[0].y === range.max)\n ) {\n sections[0].push({ x: domain.min, y: range.max });\n sections[1].push({ x: domain.max, y: range.max }, { x: domain.max, y: range.min }, { x: domain.min, y: range.min });\n } else if (\n (intersectionPoint[0].x === domain.min && intersectionPoint[1].y === range.min) ||\n (intersectionPoint[1].x === domain.min && intersectionPoint[0].y === range.min)\n ) {\n sections[0].push({ x: domain.min, y: range.min });\n sections[1].push({ x: domain.max, y: range.min }, { x: domain.max, y: range.max }, { x: domain.min, y: range.max });\n } else if (\n (intersectionPoint[0].x === domain.max && intersectionPoint[1].y === range.min) ||\n (intersectionPoint[1].x === domain.max && intersectionPoint[0].y === range.min)\n ) {\n sections[0].push({ x: domain.max, y: range.min });\n sections[1].push({ x: domain.min, y: range.min }, { x: domain.min, y: range.max }, { x: domain.max, y: range.max });\n } else if (\n (intersectionPoint[0].x === domain.min && intersectionPoint[1].x === domain.max) ||\n (intersectionPoint[0].x === domain.max && intersectionPoint[1].x === domain.min)\n ) {\n sections[0].push({ x: domain.min, y: range.max }, { x: domain.max, y: range.max });\n sections[1].push({ x: domain.min, y: range.min }, { x: domain.max, y: range.min });\n } else if (\n (intersectionPoint[0].y === range.min && intersectionPoint[1].y === range.max) ||\n (intersectionPoint[0].y === range.max && intersectionPoint[1].y === range.min)\n ) {\n sections[0].push({ x: domain.min, y: range.min }, { x: domain.min, y: range.max });\n sections[1].push({ x: domain.max, y: range.min }, { x: domain.max, y: range.max });\n }\n return removeDuplicateAndFilterSections(sections);\n};\n\n/*\n * Function to find sections in solution set for two lines\n * @param {Object} gssLineData - graphing solution set line data\n * @param {Array} answers - answers array\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst findSectionsInSolutionSetForTwoLines = (gssLineData, answers, domain, range) => {\n let mark1 = answers[0];\n let mark2 = answers[1];\n let cornerPoints = [\n { x: domain.min, y: range.min },\n { x: domain.min, y: range.max },\n { x: domain.max, y: range.min },\n { x: domain.max, y: range.max },\n ];\n let intersectPoint = lineIntersect(\n mark1.from.x,\n mark1.from.y,\n mark1.to.x,\n mark1.to.y,\n mark2.from.x,\n mark2.from.y,\n mark2.to.x,\n mark2.to.y,\n );\n let sections = [];\n let intersectionPoint1 = findIntersectionPointForMark(mark1, domain, range);\n intersectionPoint1 = removeDuplicatesFromArray(intersectionPoint1);\n let intersectionPoint2 = findIntersectionPointForMark(mark2, domain, range);\n intersectionPoint2 = removeDuplicatesFromArray(intersectionPoint2);\n if (intersectPoint && isPointInsideGraph(intersectPoint, domain, range)) {\n for (let i = 0; i < intersectionPoint1.length; i++) {\n for (let j = 0; j < intersectionPoint2.length; j++) {\n let bucket = [];\n let newCornerPoints = [];\n bucket.push(intersectPoint);\n bucket.push(intersectionPoint1[i]);\n bucket.push(intersectionPoint2[j]);\n for (let k = 0; k < cornerPoints.length; k++) {\n if (pointInAngle(intersectPoint, intersectionPoint1[i], intersectionPoint2[j], cornerPoints[k])) {\n bucket.push(cornerPoints[k]);\n } else {\n newCornerPoints.push(cornerPoints[k]);\n }\n }\n cornerPoints = newCornerPoints;\n sections.push(bucket);\n }\n }\n } else {\n let sections1 = findSectionsInSolutionSetForOneLine(intersectionPoint1, domain, range);\n let sections2 = findSectionsInSolutionSetForOneLine(intersectionPoint2, domain, range);\n for (let i = 0; i < sections1.length; i++) {\n if (\n !(pointInPolygon(intersectionPoint2[0], sections1[i]) && pointInPolygon(intersectionPoint2[1], sections1[i]))\n ) {\n sections.push(sections1[i]);\n }\n }\n for (let i = 0; i < sections2.length; i++) {\n if (\n !(pointInPolygon(intersectionPoint1[0], sections2[i]) && pointInPolygon(intersectionPoint1[1], sections2[i]))\n ) {\n sections.push(sections2[i]);\n }\n }\n for (let i = 0; i < sections.length; i++) {\n cornerPoints = cornerPoints.filter(function (o1) {\n return !sections[i].some(function (o2) {\n return o1.x === o2.x && o1.y === o2.y;\n });\n });\n }\n let sections3 = cornerPoints.concat(intersectionPoint1, intersectionPoint2);\n sections.push(sections3);\n }\n return removeDuplicateAndFilterSections(sections);\n};\n\n/*\n * Function to find sections in solution set\n * @param {Object} gssLineData - graphing solution set line data\n * @param {Array} answers - answers array\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nexport const findSectionsInSolutionSet = (gssLineData, answers, domain, range) => {\n if (gssLineData.numberOfLines === 1) {\n const intersectionPoint = findIntersectionPointForMark(answers[0], domain, range);\n gssLineData.sections = findSectionsInSolutionSetForOneLine(intersectionPoint, domain, range);\n } else {\n gssLineData.sections = findSectionsInSolutionSetForTwoLines(gssLineData, answers, domain, range);\n }\n return gssLineData;\n};\n\n/*\n * Function to check if a point is inside a polygon\n * @param {Object} point - point to be checked\n * @param {Array} polygon - polygon points array\n * */\nexport const pointInsidePolygon = (point, polygon) => {\n const num_vertices = polygon.length;\n const x = point.x;\n const y = point.y;\n let inside = false;\n let p1 = polygon[0];\n let p2;\n for (let i = 1; i <= num_vertices; i++) {\n p2 = polygon[i % num_vertices];\n if (y > Math.min(p1.y, p2.y)) {\n if (y <= Math.max(p1.y, p2.y)) {\n if (x <= Math.max(p1.x, p2.x)) {\n const x_intersection = ((y - p1.y) * (p2.x - p1.x)) / (p2.y - p1.y) + p1.x;\n if (p1.x === p2.x || x <= x_intersection) {\n inside = !inside;\n }\n }\n }\n }\n p1 = p2;\n }\n return inside;\n};\n\n/*\n * Function to check if lines are added in the graph\n * @param {Object} gssLineData - graphing solution set line data\n * @param {Array} answer - answer array\n * */\nexport const checkIfLinesAreAdded = (gssLineData, answer) => {\n if (answer.length === 0) {\n return false;\n }\n if (gssLineData.numberOfLines === 1) {\n if (answer.length === 1) {\n return !answer[0].building;\n }\n } else {\n if (answer.length !== 2) {\n return false;\n } else {\n return !answer[1].building;\n }\n }\n};\n\n/*\n * Function to remove invalid answers\n * @param {Array} answers - answers array\n * */\nexport const removeInvalidAnswers = (answers) =>\n answers\n ? (answers || []).filter(({ type, ...answer }) => (completeMark[type] ? completeMark[type](answer) : false))\n : [];\n"],"file":"utils.js"}
|