New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

triangle-triangle-intersection-js

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

triangle-triangle-intersection-js

[![build](https://github.com/LokiResearch/triangle-triangle-intersection-js/actions/workflows/node.js.yml/badge.svg)](https://github.com/LokiResearch/triangle-triangle-intersection-js/actions/workflows/node.js.yml)

unpublished
latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

triangle-triangle-intersection-js

build

Fast triangle-triangle intersection computation with high precision and cross/coplanar triangles handling.

Typescript definitions are included.

Install

npm i triangle-triangle-intersection-js

Documentation

trianglesIntersect(t1: Triangle, t2: Triangle, target?: Array<Vector3>): Intersection

Computes wether triangle t1 and t2 are intersecting and returns Intersection.Cross if triangles are cross-intersecting, Intersection.Coplanar if triangles are coplanar-intersecting, otherwise returns null. If target array is given, it is emptied and intersection points are then computed and put in the array.

Use

Check if triangles are simply intersecting.

import {Triangle} from 'three';
import {trianglesIntersect, Intersection} from 'triangle-triangle-intersection-js';

const t1 = new Triangle();
t1.a.set(-1, 0, 0);
t1.b.set(2, 0, -2);
t1.c.set(2, 0, 2);

const t2 = new Triangle();
t2.a.set(1, 0, 0);
t2.b.set(-2, -2, 0);
t2.c.set(-2, 2, 0);

const intersection = trianglesIntersect(t1, t2);
if (intersection === Intersection.Cross) {
  console.log("Triangles are cross-intersecting.");
} else if (intersection === Intersection.Coplanar) {
  console.log("Triangles are coplanar-intersecting.");
} else {
  console.log("Triangles are not intersecting.");
}

Obtening the intersection points.

const points = new Array<Vector3>();
if (trianglesIntersect(t1, t2, points)) {
  console.log("Intersection points: ", points) // [Vector3(1, 0, 0), Vector3(-1, 0, 0)]
}

Info

This algorithm is based on this publication.

@techreport{devillers:inria-00072100,
  TITLE = {{Faster Triangle-Triangle Intersection Tests}},
  AUTHOR = {Devillers, Olivier and Guigue, Philippe},
  URL = {https://hal.inria.fr/inria-00072100},
  NUMBER = {RR-4488},
  INSTITUTION = {{INRIA}},
  YEAR = {2002},
  MONTH = Jun,
  KEYWORDS = {LOW DEGREE PREDICATE ; COLLISION DETECTION ; GEOMETRIC PREDICATES},
  PDF = {https://hal.inria.fr/inria-00072100/file/RR-4488.pdf},
  HAL_ID = {inria-00072100},
  HAL_VERSION = {v1},
}

FAQs

Package last updated on 28 Feb 2022

Did you know?

Socket

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.

Install

Related posts