From: Scott Worley Date: Thu, 20 Dec 2012 09:18:52 +0000 (-0800) Subject: Cones. X-Git-Url: http://git.scottworley.com/nt3d/commitdiff_plain/1a18e646fe84c30984a5298c284d959e925e6a54?ds=sidebyside Cones. (Cones are the first primitive solid because 3-sided cones are basically cheap arrows that can be littered all over the place for debugging.) --- diff --git a/cone_primitive.html b/cone_primitive.html new file mode 100644 index 0000000..19a7686 --- /dev/null +++ b/cone_primitive.html @@ -0,0 +1,18 @@ + + + Cone primitive + + + + +

Cone primitive

+

There's a cone primitive.

+ + diff --git a/nt3d.js b/nt3d.js index 7472548..0443913 100644 --- a/nt3d.js +++ b/nt3d.js @@ -55,6 +55,13 @@ nt3d = { } return points; }, + cone: function(base_center, apex, radius, steps) { + var base = this.circle(radius, steps); + base = this.rotate_onto(base, [0,0,1], this.sub(apex, base_center)); + base = this.translate(base, base_center); + return this.closed_trianglefan([apex].concat(base)).concat( + this.trianglefan(base.reverse())); + }, extrude: function(shape, path, shapenormals, pathnormals) { var guts_result = nt3d._extrude_guts(shape, path, shapenormals, pathnormals); // Add the end-caps