New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/geom-isec

Package Overview
Dependencies
Maintainers
1
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/geom-isec - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

4

api.js

@@ -1,1 +0,3 @@

export const NONE = Object.freeze({ type: 0 /* NONE */ });
export const NONE = Object.freeze({
type: 0 /* NONE */
});

@@ -6,2 +6,10 @@ # Change Log

## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.4...@thi.ng/geom-isec@0.1.5) (2019-03-01)
**Note:** Version bump only for package @thi.ng/geom-isec
## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-isec@0.1.3...@thi.ng/geom-isec@0.1.4) (2019-02-26)

@@ -8,0 +16,0 @@

@@ -19,11 +19,12 @@ 'use strict';

const classifyPointInCircle = (p, pos, r, eps = math.EPS) => math.sign(r * r - vectors.distSq(pos, p), eps);
const pointInCircumCircle = (a, b, c, d) => (vectors.magSq(a) * vectors.signedArea2(b, c, d) -
const pointInCircumCircle = (a, b, c, d) => vectors.magSq(a) * vectors.signedArea2(b, c, d) -
vectors.magSq(b) * vectors.signedArea2(a, c, d) +
vectors.magSq(c) * vectors.signedArea2(a, b, d) -
vectors.magSq(d) * vectors.signedArea2(a, b, c)) > 0;
vectors.magSq(d) * vectors.signedArea2(a, b, c) >
0;
const pointInTriangle2 = (p, a, b, c) => {
const s = vectors.clockwise2(a, b, c) ? 1 : -1;
return s * vectors.signedArea2(a, c, p) >= 0 &&
return (s * vectors.signedArea2(a, c, p) >= 0 &&
s * vectors.signedArea2(b, a, p) >= 0 &&
s * vectors.signedArea2(c, b, p) >= 0;
s * vectors.signedArea2(c, b, p) >= 0);
};

@@ -46,12 +47,19 @@ const classifyPointInTriangle2 = (p, a, b, c, eps = math.EPS) => {

};
const classifyPointPolyPair = (px, py, ax, ay, bx, by, inside) => ((ay < py && by >= py) || (by < py && ay >= py)) && (ax <= px || bx <= px) ?
inside ^ (((ax + (py - ay) / (by - ay) * (bx - ax)) < px) ? 1 : 0) :
inside;
const pointInAABB = ([x, y, z], pos, size) => x >= pos[0] && x <= pos[0] + size[0] &&
y >= pos[1] && y <= pos[1] + size[1] &&
z >= pos[2] && z <= pos[2] + size[2];
const pointInRect = ([x, y], pos, size) => x >= pos[0] && x <= pos[0] + size[0] &&
y >= pos[1] && y <= pos[1] + size[1];
const classifyPointPolyPair = (px, py, ax, ay, bx, by, inside) => ((ay < py && by >= py) || (by < py && ay >= py)) && (ax <= px || bx <= px)
? inside ^ (ax + ((py - ay) / (by - ay)) * (bx - ax) < px ? 1 : 0)
: inside;
const pointInAABB = ([x, y, z], pos, size) => x >= pos[0] &&
x <= pos[0] + size[0] &&
y >= pos[1] &&
y <= pos[1] + size[1] &&
z >= pos[2] &&
z <= pos[2] + size[2];
const pointInRect = ([x, y], pos, size) => x >= pos[0] &&
x <= pos[0] + size[0] &&
y >= pos[1] &&
y <= pos[1] + size[1];
const NONE = Object.freeze({ type: 0 });
const NONE = Object.freeze({
type: 0
});

@@ -94,6 +102,6 @@ const intersectCircleCircle = (a, b, ar, br) => {

return {
type: isec ?
2 :
3 ,
isec,
type: isec
? 2
: 3 ,
isec
};

@@ -107,9 +115,9 @@ }

return {
type: (eps < alpha && alpha < ieps) && (eps < beta && beta < ieps) ?
4 :
5 ,
type: eps < alpha && alpha < ieps && (eps < beta && beta < ieps)
? 4
: 5 ,
isec: vectors.mixN2([], a, b, alpha),
alpha,
beta,
det,
det
};

@@ -127,14 +135,12 @@ };

const b = w - d;
const isec = a >= 0 ?
b >= 0 ?
a > b ?
[vectors.maddN(delta, rpos, dir, b), vectors.maddN([], rpos, dir, a)] :
[vectors.maddN(delta, rpos, dir, a), vectors.maddN([], rpos, dir, b)] :
[vectors.maddN(delta, rpos, dir, a)] :
b >= 0 ?
[vectors.maddN(delta, rpos, dir, b)] :
undefined;
return isec ?
{ type: 4 , isec } :
NONE;
const isec = a >= 0
? b >= 0
? a > b
? [vectors.maddN(delta, rpos, dir, b), vectors.maddN([], rpos, dir, a)]
: [vectors.maddN(delta, rpos, dir, a), vectors.maddN([], rpos, dir, b)]
: [vectors.maddN(delta, rpos, dir, a)]
: b >= 0
? [vectors.maddN(delta, rpos, dir, b)]
: undefined;
return isec ? { type: 4 , isec } : NONE;
}

@@ -154,9 +160,9 @@ };

const s = (dir[1] * arx - dir[0] * ary) / d;
return t >= 0 && s >= 0 && s <= 1 ?
{
return t >= 0 && s >= 0 && s <= 1
? {
type: 4 ,
isec: vectors.maddN([], rpos, dir, t),
alpha: t
} :
NONE;
}
: NONE;
};

@@ -185,10 +191,10 @@

}
return cross > 0 ?
{
return cross > 0
? {
type: 4 ,
isec: vectors.maddN2([], rpos, dir, minD),
inside: !(cross & 1),
alpha: minD,
} :
NONE;
alpha: minD
}
: NONE;
};

@@ -213,8 +219,8 @@ const intersectRayPolylineAll = (rpos, dir, pts, closed = false) => {

}
return res.length ?
{
return res.length
? {
type: 4 ,
isec: res.sort((a, b) => a[0] - b[0]).map((x) => x[1])
} :
NONE;
}
: NONE;
};

@@ -230,3 +236,3 @@

let tmax = max(t1, t2);
p = rpos[1], d = 1 / dir[1];
(p = rpos[1]), (d = 1 / dir[1]);
t1 = (bmin[1] - p) * d;

@@ -242,6 +248,6 @@ t2 = (bmax[1] - p) * d;

let tmax = max(t1, t2);
p = rpos[1], d = 1 / dir[1];
(p = rpos[1]), (d = 1 / dir[1]);
t1 = (bmin[1] - p) * d;
t2 = (bmax[1] - p) * d;
p = rpos[2], d = 1 / dir[2];
(p = rpos[2]), (d = 1 / dir[2]);
t1 = (bmin[2] - p) * d;

@@ -258,17 +264,20 @@ t2 = (bmax[2] - p) * d;

const inside = tmin < 0;
return tmax > max(tmin, 0) ?
inside ?
{
return tmax > max(tmin, 0)
? inside
? {
type: 4 ,
inside,
isec: [vectors.maddN([], rpos, dir, tmax)],
alpha: tmax,
} :
{
alpha: tmax
}
: {
type: 4 ,
isec: [vectors.maddN([], rpos, dir, tmin), vectors.maddN([], rpos, dir, tmax)],
isec: [
vectors.maddN([], rpos, dir, tmin),
vectors.maddN([], rpos, dir, tmax)
],
alpha: tmin,
beta: tmax,
} :
NONE;
beta: tmax
}
: NONE;
};

@@ -286,23 +295,13 @@ const intersectRayRect = intersectWith(rayRect);

const testRectCircle = ([rx, ry], [w, h], [cx, cy], r) => (axis(cx, rx, w) +
axis(cy, ry, h)) <= r * r;
const testAABBSphere = ([rx, ry, rz], [w, h, d], [cx, cy, cz], r) => (axis(cx, rx, w) +
axis(cy, ry, h) +
axis(cz, rz, d)) <= r * r;
const axis = (a, b, c) => Math.pow(a < b ?
a - b :
a > b + c ?
a - b - c :
0, 2);
const testRectCircle = ([rx, ry], [w, h], [cx, cy], r) => axis(cx, rx, w) + axis(cy, ry, h) <= r * r;
const testAABBSphere = ([rx, ry, rz], [w, h, d], [cx, cy, cz], r) => axis(cx, rx, w) + axis(cy, ry, h) + axis(cz, rz, d) <= r * r;
const axis = (a, b, c) => Math.pow(a < b ? a - b : a > b + c ? a - b - c : 0, 2);
const testRectRect = ([ax, ay], [aw, ah], [bx, by], [bw, bh]) => !((ax > bx + bw) ||
(bx > ax + aw) ||
(ay > by + bh) ||
(by > ay + ah));
const testAabbAabb = ([ax, ay, az], [aw, ah, ad], [bx, by, bz], [bw, bh, bd]) => !((ax > bx + bw) ||
(bx > ax + aw) ||
(ay > by + bh) ||
(by > ay + ah) ||
(az > bz + bd) ||
(bz > az + ad));
const testRectRect = ([ax, ay], [aw, ah], [bx, by], [bw, bh]) => !(ax > bx + bw || bx > ax + aw || ay > by + bh || by > ay + ah);
const testAabbAabb = ([ax, ay, az], [aw, ah, ad], [bx, by, bz], [bw, bh, bd]) => !(ax > bx + bw ||
bx > ax + aw ||
ay > by + bh ||
by > ay + ah ||
az > bz + bd ||
bz > az + ad);

@@ -309,0 +308,0 @@ exports.pointInSegment2 = pointInSegment2;

@@ -17,11 +17,12 @@ (function (global, factory) {

const classifyPointInCircle = (p, pos, r, eps = math.EPS) => math.sign(r * r - vectors.distSq(pos, p), eps);
const pointInCircumCircle = (a, b, c, d) => (vectors.magSq(a) * vectors.signedArea2(b, c, d) -
const pointInCircumCircle = (a, b, c, d) => vectors.magSq(a) * vectors.signedArea2(b, c, d) -
vectors.magSq(b) * vectors.signedArea2(a, c, d) +
vectors.magSq(c) * vectors.signedArea2(a, b, d) -
vectors.magSq(d) * vectors.signedArea2(a, b, c)) > 0;
vectors.magSq(d) * vectors.signedArea2(a, b, c) >
0;
const pointInTriangle2 = (p, a, b, c) => {
const s = vectors.clockwise2(a, b, c) ? 1 : -1;
return s * vectors.signedArea2(a, c, p) >= 0 &&
return (s * vectors.signedArea2(a, c, p) >= 0 &&
s * vectors.signedArea2(b, a, p) >= 0 &&
s * vectors.signedArea2(c, b, p) >= 0;
s * vectors.signedArea2(c, b, p) >= 0);
};

@@ -44,12 +45,19 @@ const classifyPointInTriangle2 = (p, a, b, c, eps = math.EPS) => {

};
const classifyPointPolyPair = (px, py, ax, ay, bx, by, inside) => ((ay < py && by >= py) || (by < py && ay >= py)) && (ax <= px || bx <= px) ?
inside ^ (((ax + (py - ay) / (by - ay) * (bx - ax)) < px) ? 1 : 0) :
inside;
const pointInAABB = ([x, y, z], pos, size) => x >= pos[0] && x <= pos[0] + size[0] &&
y >= pos[1] && y <= pos[1] + size[1] &&
z >= pos[2] && z <= pos[2] + size[2];
const pointInRect = ([x, y], pos, size) => x >= pos[0] && x <= pos[0] + size[0] &&
y >= pos[1] && y <= pos[1] + size[1];
const classifyPointPolyPair = (px, py, ax, ay, bx, by, inside) => ((ay < py && by >= py) || (by < py && ay >= py)) && (ax <= px || bx <= px)
? inside ^ (ax + ((py - ay) / (by - ay)) * (bx - ax) < px ? 1 : 0)
: inside;
const pointInAABB = ([x, y, z], pos, size) => x >= pos[0] &&
x <= pos[0] + size[0] &&
y >= pos[1] &&
y <= pos[1] + size[1] &&
z >= pos[2] &&
z <= pos[2] + size[2];
const pointInRect = ([x, y], pos, size) => x >= pos[0] &&
x <= pos[0] + size[0] &&
y >= pos[1] &&
y <= pos[1] + size[1];
const NONE = Object.freeze({ type: 0 });
const NONE = Object.freeze({
type: 0
});

@@ -92,6 +100,6 @@ const intersectCircleCircle = (a, b, ar, br) => {

return {
type: isec ?
2 :
3 ,
isec,
type: isec
? 2
: 3 ,
isec
};

@@ -105,9 +113,9 @@ }

return {
type: (eps < alpha && alpha < ieps) && (eps < beta && beta < ieps) ?
4 :
5 ,
type: eps < alpha && alpha < ieps && (eps < beta && beta < ieps)
? 4
: 5 ,
isec: vectors.mixN2([], a, b, alpha),
alpha,
beta,
det,
det
};

@@ -125,14 +133,12 @@ };

const b = w - d;
const isec = a >= 0 ?
b >= 0 ?
a > b ?
[vectors.maddN(delta, rpos, dir, b), vectors.maddN([], rpos, dir, a)] :
[vectors.maddN(delta, rpos, dir, a), vectors.maddN([], rpos, dir, b)] :
[vectors.maddN(delta, rpos, dir, a)] :
b >= 0 ?
[vectors.maddN(delta, rpos, dir, b)] :
undefined;
return isec ?
{ type: 4 , isec } :
NONE;
const isec = a >= 0
? b >= 0
? a > b
? [vectors.maddN(delta, rpos, dir, b), vectors.maddN([], rpos, dir, a)]
: [vectors.maddN(delta, rpos, dir, a), vectors.maddN([], rpos, dir, b)]
: [vectors.maddN(delta, rpos, dir, a)]
: b >= 0
? [vectors.maddN(delta, rpos, dir, b)]
: undefined;
return isec ? { type: 4 , isec } : NONE;
}

@@ -152,9 +158,9 @@ };

const s = (dir[1] * arx - dir[0] * ary) / d;
return t >= 0 && s >= 0 && s <= 1 ?
{
return t >= 0 && s >= 0 && s <= 1
? {
type: 4 ,
isec: vectors.maddN([], rpos, dir, t),
alpha: t
} :
NONE;
}
: NONE;
};

@@ -183,10 +189,10 @@

}
return cross > 0 ?
{
return cross > 0
? {
type: 4 ,
isec: vectors.maddN2([], rpos, dir, minD),
inside: !(cross & 1),
alpha: minD,
} :
NONE;
alpha: minD
}
: NONE;
};

@@ -211,8 +217,8 @@ const intersectRayPolylineAll = (rpos, dir, pts, closed = false) => {

}
return res.length ?
{
return res.length
? {
type: 4 ,
isec: res.sort((a, b) => a[0] - b[0]).map((x) => x[1])
} :
NONE;
}
: NONE;
};

@@ -228,3 +234,3 @@

let tmax = max(t1, t2);
p = rpos[1], d = 1 / dir[1];
(p = rpos[1]), (d = 1 / dir[1]);
t1 = (bmin[1] - p) * d;

@@ -240,6 +246,6 @@ t2 = (bmax[1] - p) * d;

let tmax = max(t1, t2);
p = rpos[1], d = 1 / dir[1];
(p = rpos[1]), (d = 1 / dir[1]);
t1 = (bmin[1] - p) * d;
t2 = (bmax[1] - p) * d;
p = rpos[2], d = 1 / dir[2];
(p = rpos[2]), (d = 1 / dir[2]);
t1 = (bmin[2] - p) * d;

@@ -256,17 +262,20 @@ t2 = (bmax[2] - p) * d;

const inside = tmin < 0;
return tmax > max(tmin, 0) ?
inside ?
{
return tmax > max(tmin, 0)
? inside
? {
type: 4 ,
inside,
isec: [vectors.maddN([], rpos, dir, tmax)],
alpha: tmax,
} :
{
alpha: tmax
}
: {
type: 4 ,
isec: [vectors.maddN([], rpos, dir, tmin), vectors.maddN([], rpos, dir, tmax)],
isec: [
vectors.maddN([], rpos, dir, tmin),
vectors.maddN([], rpos, dir, tmax)
],
alpha: tmin,
beta: tmax,
} :
NONE;
beta: tmax
}
: NONE;
};

@@ -284,23 +293,13 @@ const intersectRayRect = intersectWith(rayRect);

const testRectCircle = ([rx, ry], [w, h], [cx, cy], r) => (axis(cx, rx, w) +
axis(cy, ry, h)) <= r * r;
const testAABBSphere = ([rx, ry, rz], [w, h, d], [cx, cy, cz], r) => (axis(cx, rx, w) +
axis(cy, ry, h) +
axis(cz, rz, d)) <= r * r;
const axis = (a, b, c) => Math.pow(a < b ?
a - b :
a > b + c ?
a - b - c :
0, 2);
const testRectCircle = ([rx, ry], [w, h], [cx, cy], r) => axis(cx, rx, w) + axis(cy, ry, h) <= r * r;
const testAABBSphere = ([rx, ry, rz], [w, h, d], [cx, cy, cz], r) => axis(cx, rx, w) + axis(cy, ry, h) + axis(cz, rz, d) <= r * r;
const axis = (a, b, c) => Math.pow(a < b ? a - b : a > b + c ? a - b - c : 0, 2);
const testRectRect = ([ax, ay], [aw, ah], [bx, by], [bw, bh]) => !((ax > bx + bw) ||
(bx > ax + aw) ||
(ay > by + bh) ||
(by > ay + ah));
const testAabbAabb = ([ax, ay, az], [aw, ah, ad], [bx, by, bz], [bw, bh, bd]) => !((ax > bx + bw) ||
(bx > ax + aw) ||
(ay > by + bh) ||
(by > ay + ah) ||
(az > bz + bd) ||
(bz > az + ad));
const testRectRect = ([ax, ay], [aw, ah], [bx, by], [bw, bh]) => !(ax > bx + bw || bx > ax + aw || ay > by + bh || by > ay + ah);
const testAabbAabb = ([ax, ay, az], [aw, ah, ad], [bx, by, bz], [bw, bh, bd]) => !(ax > bx + bw ||
bx > ax + aw ||
ay > by + bh ||
by > ay + ah ||
az > bz + bd ||
bz > az + ad);

@@ -307,0 +306,0 @@ exports.pointInSegment2 = pointInSegment2;

@@ -19,6 +19,6 @@ import { closestPointSegment } from "@thi.ng/geom-closest-point";

return {
type: isec ?
2 /* COINCIDENT */ :
3 /* COINCIDENT_NO_INTERSECT */,
isec,
type: isec
? 2 /* COINCIDENT */
: 3 /* COINCIDENT_NO_INTERSECT */,
isec
};

@@ -32,9 +32,9 @@ }

return {
type: (eps < alpha && alpha < ieps) && (eps < beta && beta < ieps) ?
4 /* INTERSECT */ :
5 /* INTERSECT_OUTSIDE */,
type: eps < alpha && alpha < ieps && (eps < beta && beta < ieps)
? 4 /* INTERSECT */
: 5 /* INTERSECT_OUTSIDE */,
isec: mixN2([], a, b, alpha),
alpha,
beta,
det,
det
};

@@ -41,0 +41,0 @@ };

{
"name": "@thi.ng/geom-isec",
"version": "0.1.4",
"version": "0.1.5",
"description": "2D/3D shape intersection checks",

@@ -35,6 +35,6 @@ "module": "./index.js",

"dependencies": {
"@thi.ng/geom-api": "^0.1.3",
"@thi.ng/geom-closest-point": "^0.1.4",
"@thi.ng/math": "^1.1.0",
"@thi.ng/vectors": "^2.3.1"
"@thi.ng/geom-api": "^0.1.4",
"@thi.ng/geom-closest-point": "^0.1.5",
"@thi.ng/math": "^1.1.1",
"@thi.ng/vectors": "^2.3.2"
},

@@ -59,3 +59,3 @@ "keywords": [

"sideEffects": false,
"gitHead": "647e13737436e44d28e151c0be8594835cf25ed0"
"gitHead": "e43f57c7554fd78380bba58d37ae62ca01221eeb"
}

@@ -13,11 +13,12 @@ import { EPS, sign } from "@thi.ng/math";

export const classifyPointInCircle = (p, pos, r, eps = EPS) => sign(r * r - distSq(pos, p), eps);
export const pointInCircumCircle = (a, b, c, d) => (magSq(a) * signedArea2(b, c, d) -
export const pointInCircumCircle = (a, b, c, d) => magSq(a) * signedArea2(b, c, d) -
magSq(b) * signedArea2(a, c, d) +
magSq(c) * signedArea2(a, b, d) -
magSq(d) * signedArea2(a, b, c)) > 0;
magSq(d) * signedArea2(a, b, c) >
0;
export const pointInTriangle2 = (p, a, b, c) => {
const s = clockwise2(a, b, c) ? 1 : -1;
return s * signedArea2(a, c, p) >= 0 &&
return (s * signedArea2(a, c, p) >= 0 &&
s * signedArea2(b, a, p) >= 0 &&
s * signedArea2(c, b, p) >= 0;
s * signedArea2(c, b, p) >= 0);
};

@@ -40,9 +41,14 @@ export const classifyPointInTriangle2 = (p, a, b, c, eps = EPS) => {

};
export const classifyPointPolyPair = (px, py, ax, ay, bx, by, inside) => ((ay < py && by >= py) || (by < py && ay >= py)) && (ax <= px || bx <= px) ?
inside ^ (((ax + (py - ay) / (by - ay) * (bx - ax)) < px) ? 1 : 0) :
inside;
export const pointInAABB = ([x, y, z], pos, size) => x >= pos[0] && x <= pos[0] + size[0] &&
y >= pos[1] && y <= pos[1] + size[1] &&
z >= pos[2] && z <= pos[2] + size[2];
export const pointInRect = ([x, y], pos, size) => x >= pos[0] && x <= pos[0] + size[0] &&
y >= pos[1] && y <= pos[1] + size[1];
export const classifyPointPolyPair = (px, py, ax, ay, bx, by, inside) => ((ay < py && by >= py) || (by < py && ay >= py)) && (ax <= px || bx <= px)
? inside ^ (ax + ((py - ay) / (by - ay)) * (bx - ax) < px ? 1 : 0)
: inside;
export const pointInAABB = ([x, y, z], pos, size) => x >= pos[0] &&
x <= pos[0] + size[0] &&
y >= pos[1] &&
y <= pos[1] + size[1] &&
z >= pos[2] &&
z <= pos[2] + size[2];
export const pointInRect = ([x, y], pos, size) => x >= pos[0] &&
x <= pos[0] + size[0] &&
y >= pos[1] &&
y <= pos[1] + size[1];

@@ -11,15 +11,13 @@ import { dot, maddN, magSq, sub } from "@thi.ng/vectors";

const b = w - d;
const isec = a >= 0 ?
b >= 0 ?
a > b ?
[maddN(delta, rpos, dir, b), maddN([], rpos, dir, a)] :
[maddN(delta, rpos, dir, a), maddN([], rpos, dir, b)] :
[maddN(delta, rpos, dir, a)] :
b >= 0 ?
[maddN(delta, rpos, dir, b)] :
undefined;
return isec ?
{ type: 4 /* INTERSECT */, isec } :
NONE;
const isec = a >= 0
? b >= 0
? a > b
? [maddN(delta, rpos, dir, b), maddN([], rpos, dir, a)]
: [maddN(delta, rpos, dir, a), maddN([], rpos, dir, b)]
: [maddN(delta, rpos, dir, a)]
: b >= 0
? [maddN(delta, rpos, dir, b)]
: undefined;
return isec ? { type: 4 /* INTERSECT */, isec } : NONE;
}
};

@@ -15,9 +15,9 @@ import { eqDeltaFixed } from "@thi.ng/math";

const s = (dir[1] * arx - dir[0] * ary) / d;
return t >= 0 && s >= 0 && s <= 1 ?
{
return t >= 0 && s >= 0 && s <= 1
? {
type: 4 /* INTERSECT */,
isec: maddN([], rpos, dir, t),
alpha: t
} :
NONE;
}
: NONE;
};

@@ -25,10 +25,10 @@ import { maddN2 } from "@thi.ng/vectors";

}
return cross > 0 ?
{
return cross > 0
? {
type: 4 /* INTERSECT */,
isec: maddN2([], rpos, dir, minD),
inside: !(cross & 1),
alpha: minD,
} :
NONE;
alpha: minD
}
: NONE;
};

@@ -53,8 +53,8 @@ export const intersectRayPolylineAll = (rpos, dir, pts, closed = false) => {

}
return res.length ?
{
return res.length
? {
type: 4 /* INTERSECT */,
isec: res.sort((a, b) => a[0] - b[0]).map((x) => x[1])
} :
NONE;
}
: NONE;
};

@@ -20,3 +20,3 @@ import { maddN } from "@thi.ng/vectors";

let tmax = max(t1, t2);
p = rpos[1], d = 1 / dir[1];
(p = rpos[1]), (d = 1 / dir[1]);
t1 = (bmin[1] - p) * d;

@@ -40,6 +40,6 @@ t2 = (bmax[1] - p) * d;

let tmax = max(t1, t2);
p = rpos[1], d = 1 / dir[1];
(p = rpos[1]), (d = 1 / dir[1]);
t1 = (bmin[1] - p) * d;
t2 = (bmax[1] - p) * d;
p = rpos[2], d = 1 / dir[2];
(p = rpos[2]), (d = 1 / dir[2]);
t1 = (bmin[2] - p) * d;

@@ -56,17 +56,20 @@ t2 = (bmax[2] - p) * d;

const inside = tmin < 0;
return tmax > max(tmin, 0) ?
inside ?
{
return tmax > max(tmin, 0)
? inside
? {
type: 4 /* INTERSECT */,
inside,
isec: [maddN([], rpos, dir, tmax)],
alpha: tmax,
} :
{
alpha: tmax
}
: {
type: 4 /* INTERSECT */,
isec: [maddN([], rpos, dir, tmin), maddN([], rpos, dir, tmax)],
isec: [
maddN([], rpos, dir, tmin),
maddN([], rpos, dir, tmax)
],
alpha: tmin,
beta: tmax,
} :
NONE;
beta: tmax
}
: NONE;
};

@@ -73,0 +76,0 @@ export const intersectRayRect = intersectWith(rayRect);

@@ -1,10 +0,3 @@

export const testRectCircle = ([rx, ry], [w, h], [cx, cy], r) => (axis(cx, rx, w) +
axis(cy, ry, h)) <= r * r;
export const testAABBSphere = ([rx, ry, rz], [w, h, d], [cx, cy, cz], r) => (axis(cx, rx, w) +
axis(cy, ry, h) +
axis(cz, rz, d)) <= r * r;
const axis = (a, b, c) => Math.pow(a < b ?
a - b :
a > b + c ?
a - b - c :
0, 2);
export const testRectCircle = ([rx, ry], [w, h], [cx, cy], r) => axis(cx, rx, w) + axis(cy, ry, h) <= r * r;
export const testAABBSphere = ([rx, ry, rz], [w, h, d], [cx, cy, cz], r) => axis(cx, rx, w) + axis(cy, ry, h) + axis(cz, rz, d) <= r * r;
const axis = (a, b, c) => Math.pow(a < b ? a - b : a > b + c ? a - b - c : 0, 2);

@@ -1,10 +0,7 @@

export const testRectRect = ([ax, ay], [aw, ah], [bx, by], [bw, bh]) => !((ax > bx + bw) ||
(bx > ax + aw) ||
(ay > by + bh) ||
(by > ay + ah));
export const testAabbAabb = ([ax, ay, az], [aw, ah, ad], [bx, by, bz], [bw, bh, bd]) => !((ax > bx + bw) ||
(bx > ax + aw) ||
(ay > by + bh) ||
(by > ay + ah) ||
(az > bz + bd) ||
(bz > az + ad));
export const testRectRect = ([ax, ay], [aw, ah], [bx, by], [bw, bh]) => !(ax > bx + bw || bx > ax + aw || ay > by + bh || by > ay + ah);
export const testAabbAabb = ([ax, ay, az], [aw, ah, ad], [bx, by, bz], [bw, bh, bd]) => !(ax > bx + bw ||
bx > ax + aw ||
ay > by + bh ||
by > ay + ah ||
az > bz + bd ||
bz > az + ad);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc