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

ray-plane-intersection

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

ray-plane-intersection

whether a picking ray intersects with a plane

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

ray-plane-intersection

stable

Whether a 3D picking ray intersects with a plane. The plane is defined as having a normal [x, y, z] and distance.

var intersect = require('ray-plane-intersection')
var origin = [1, 0, 4]
var dir = [0, 0, -1]
var normal = [0, 0, 1]
var distance = 0

var hit = intersect(out, origin, dir, normal, distance) 

if (hit) { //collision occurred 
  console.log(hit) // [1, 0, 0]
}

The distance can be determined with a second point on the plane, like so:

var d = -dot(normal, point)

PRs welcome.

Usage

NPM

hit = intersect(out, origin, direction, normal, distance)

Test whether the ray (origin, direction) intersects with the plane (normal, distance).

If an intersection occurs, it is stored in out [x, y, z] and returned. Otherwise null is returned.

See Also

License

MIT, see LICENSE.md for details.

Keywords

plane

FAQs

Package last updated on 15 May 2015

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