round-cone-distance

1.0.11 • Public • Published

round-cone-distance

Highly optimized signed distance function for rounded cones (aka lozenges with different-sized "ends") in javascript.

Derived from a GLSL distance function by inigo quilez.

candy corn

Installation

npm i round-cone-distance

Usage

var rcd = require('round-cone-distance');

var r0 = 1;
var r1 = 5;
var pointA = [0,0,0];
var pointB = [10,3,-5];

var samplingPoint = [10,10,10];

var distance = rcd.roundConeDistance(samplingPoint, pointA, pointB, r0,r1);
console.log(distance) //12.493968786553904

var distanceSquared = rcd.roundConeDistanceSquared(samplingPoint, pointA, pointB, r0,r1);
console.log(distanceSquared) //248.8507665662628

Package Sidebar

Install

npm i round-cone-distance

Weekly Downloads

2

Version

1.0.11

License

MIT

Unpacked Size

3.91 kB

Total Files

4

Last publish

Collaborators

  • bonsai3d