round-cone-distance
v1.0.11
Published
optimized signed distance function for rounded cones (aka lozenges with different-sized "ends")
Downloads
6
Maintainers
Readme
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.
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