Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit 554462a391a8558ce91cb2e407e2b446e1cb9ac9 @pboyer committed Feb 15, 2013
Showing with 38,860 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +3 −0 README.md
  3. +96 −0 example/curve.html
  4. +35,788 −0 example/js/Three.js
  5. +512 −0 example/js/TrackballControls.js
  6. +6 −0 example/js/stats.js
  7. +368 −0 example/surface.html
  8. +11 −0 package.json
  9. +912 −0 src/nurbs.js
  10. +409 −0 src/nurbs_objects.js
  11. +743 −0 test/test.js
@@ -0,0 +1,12 @@
+coverage.html
+.DS_Store
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.swp
+*.swo
+node_modules/
@@ -0,0 +1,3 @@
+verb is a tiny NURBS kernel for javascript, intended to run in browsers, although it will also run in node. It aims to provide non-blocking geometric operations via Web Workers. It currently implements NURBS evaluation and defines several data types for manipulating curves and surfaces.
+
+verb is currently undergoing rapid changes and does not have a dependable API.
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+<body>
+
+
+<canvas id="myCanvas" width="800" height="800" style="border:1px solid #d3d3d3;">
+Your browser does not support the HTML5 canvas tag.</canvas>
+
+<script src="../node_modules/numeric/numeric-1.2.6.min.js"></script>
+<script src="../nurbs.js"></script>
+
+<script>
+
+ // var degree = 2
+ // , n = 6
+ // , u = 0
+ // , knot_vector = [0, 0, 0, 1, 2, 3, 4, 5, 5, 5]
+ // , control_points = [ [50, 80], [120, 50], [200, 100], [200, 150], [250, 200], [300, 150], [320, 200] ]
+ // , p = [];
+
+ // var c=document.getElementById("myCanvas");
+ // var ctx=c.getContext("2d");
+ // ctx.beginPath();
+
+ // ctx.moveTo(50,80);
+
+ // for (var i = 0; i < 100; i++)
+ // {
+ // u = 5 * (i / 99 );
+ // p = nurbs.curve_point( degree, knot_vector, control_points, u);
+ // console.log(u);
+ // console.log(p);
+ // ctx.lineTo(p[0],p[1]);
+
+ // }
+ // ctx.stroke();
+
+ // control_points.every(function(elem) {
+ // ctx.beginPath();
+ // ctx.arc(elem[0],elem[1],5,0,2*Math.PI);
+ // ctx.stroke();
+ // return true;
+ // });
+
+ var degree = 3
+ , n = 4
+ , u = 0
+ , knot_vector = [0, 0, 0, 0, 1, 1, 1, 1]
+ , control_points = [ [20, 400], [120, 50], [240, 50], [400, 400] ]
+ , p = [];
+
+ var c=document.getElementById("myCanvas");
+ var ctx=c.getContext("2d");
+ ctx.beginPath();
+
+ ctx.moveTo(20, 400);
+ for (var i = 0; i < 100; i++)
+ {
+ u = 1 * (i / 99 );
+ p = nurbs.curve_point( degree, knot_vector, control_points, u);
+ ctx.lineTo(p[0],p[1]);
+
+ }
+ ctx.stroke();
+
+ for (var i = 0; i < 10; i++)
+ {
+ u = 1 * (i / 9 );
+ console.log( u );
+ p = nurbs.curve_derivs_given_n( n, degree, knot_vector, control_points, u, 3 );
+
+ ctx.strokeStyle="red";
+
+ // first derivative
+ ctx.beginPath();
+ ctx.moveTo( p[0][0], p[0][1] );
+ ctx.lineTo( p[0][0] + 0.2 * p[1][0], p[0][1] + 0.2 * p[1][1] );
+ ctx.stroke();
+
+ }
+
+ ctx.strokeStyle="black";
+ control_points.every(function(elem) {
+ ctx.beginPath();
+ ctx.arc(elem[0],elem[1],5,0,2*Math.PI);
+ ctx.stroke();
+ return true;
+ });
+
+
+
+</script>
+
+</body>
+</html>
+
Oops, something went wrong.

0 comments on commit 554462a

Please sign in to comment.