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

ray-sphere-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-sphere-intersection

test whether a ray intersects with a sphere

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

ray-sphere-intersection

stable

Test whether a ray intersects with a sphere.

var intersect = require('ray-sphere-intersection')

var origin = [0, 0, 4], 
    direction = [0, 0, -1], 
    center = [0, 0, 0], 
    radius = 1

var hit = intersect([], origin, direction, center, radius)

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

Adapted from LibGDX. PRs for optimizations/etc welcome.

Usage

NPM

out = intersect(out, origin, direction, center, radius)

Determines if the 3D ray (origin, direction) intersects with the 3D sphere (center, radius).

If no intersection occurs, returns null. Otherwise, the intersection point is stored in out and then returned.

License

MIT, see LICENSE.md for details.

Keywords

sphere

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