chore: Cleanup intersect

This commit is contained in:
Sidharth Vinod 2024-06-29 03:06:53 +05:30
parent 9cc59f0206
commit 67c1eb34eb
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
5 changed files with 2 additions and 32 deletions

View File

@ -1,10 +1,5 @@
import intersectEllipse from './intersect-ellipse.js';
/**
* @param node
* @param rx
* @param point
*/
function intersectCircle(node, rx, point) {
return intersectEllipse(node, rx, rx, point);
}

View File

@ -1,9 +1,3 @@
/**
* @param node
* @param rx
* @param ry
* @param point
*/
function intersectEllipse(node, rx, ry, point) {
// Formulae from: https://mathworld.wolfram.com/Ellipse-LineIntersection.html

View File

@ -1,10 +1,5 @@
/**
* Returns the point at which two lines, p and q, intersect or returns undefined if they do not intersect.
*
* @param p1
* @param p2
* @param q1
* @param q2
*/
function intersectLine(p1, p2, q1, q2) {
// Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994,
@ -67,10 +62,6 @@ function intersectLine(p1, p2, q1, q2) {
return { x: x, y: y };
}
/**
* @param r1
* @param r2
*/
function sameSign(r1, r2) {
return r1 * r2 > 0;
}

View File

@ -1,7 +1,3 @@
/**
* @param node
* @param point
*/
function intersectNode(node, point) {
return node.intersect(point);
}

View File

@ -1,16 +1,8 @@
/* eslint "no-console": off */
import intersectLine from './intersect-line.js';
export default intersectPolygon;
/**
* Returns the point ({x, y}) at which the point argument intersects with the node argument assuming
* that it has the shape specified by polygon.
*
* @param node
* @param polyPoints
* @param point
*/
function intersectPolygon(node, polyPoints, point) {
let x1 = node.x;
@ -67,3 +59,5 @@ function intersectPolygon(node, polyPoints, point) {
}
return intersections[0];
}
export default intersectPolygon;