
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@kninnug/containing-triangle
Advanced tools
Find the triangle of a Delaunator triangulation that contains a given point
Find the triangle of a Delaunator triangulation that contains a given point.

// Points to be triangulated
const points = [[53,98],[5,201],[194,288],[280,195],[392,148],[413,43],[278,5],[169,71],[146,171]],
// Edges to be constrained (optional)
edges = [[5, 8]],
// Triangulate
del = Delaunator.from(points),
// (Optional: constrain the triangulation)
con = new Constrainautor(del).constrainAll(edges),
// Find the triangle that contains the point (178, 190)
tri = containingTriangle(del, 178, 190);
// tri has triangle id: 3
Install from NPM:
npm install @kninnug/containing-triangle
Use in Node.js:
const containingTriangle = require('@kninnug/containing-triangle'),
isInTriangulation = containingTriangle.isInTriangulation;
or as an ECMAScript/ES6 module:
import containingTriangle, {isInTriangulation} from '@kninnug/containing-triangle';
or in the browser:
<script src="node_modules/@kninnug/containing-triangle/lib/containing-triangle.js"></script>
or minified:
<script src="node_modules/@kninnug/containing-triangle/lib/containing-triangle.min.js"></script>
The containing-triangle library does not depend on Delaunator itself, but the
input is expected to be in the format that Delaunator outputs. The ES module
variant (lib/containing-triangle.mjs) depends on robust-predicates,
but the CommonJS, browser, and minified versions (lib/containing-triangle.cjs,
lib/containing-triangle.js, and lib/containing-triangle.min.js) come with
this dependency compiled in, and can be used standalone. The (source)
TypeScript version is in Constrainautor.ts.
Given a triangulation from Delaunator: del, and the coordinates of a point
(x, y), finds the triangle that contains that point. Returns the triangle
id, or -1 if the point
is outside the hull of the triangulation, i.e. not in any of its triangles.
Whether a point (x, y) is within the hull of the given triangulation. Should
generally be faster if you only want to know if the point is in the
triangulation and don't care what triangle it's in.
lib/.isInTriangulation function.FAQs
Find the triangle of a Delaunator triangulation that contains a given point
We found that @kninnug/containing-triangle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.