Skip to content

Commit

Permalink
separate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
enkimute committed Aug 13, 2017
1 parent 27c0bcf commit bafdb40
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/example_hue.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<BODY>
<SCRIPT>

/* In Vector space R3, rotate a color around the hue axis and output
* the result using the graph function.
*/

var R3 = Algebra(3);

var canvas = R3.graph(function(x,y){
Expand Down
5 changes: 5 additions & 0 deletions examples/example_mandelbrot.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
<BODY>
<SCRIPT>

// Create a complex Algebra.
var Complex = Algebra(0,1);

// Graph a two dimensional function to a canvas.
// In this case we output the iterations it takes for z*z+c to converge to
// infinity. (well, more than 2).
var canvas = Complex.graph(function(x,y){
var n=110, z=0e1, c=x*1.75-1+y*1e1;
while (z < 2 && n--) z=z**2+c;
return (n/100);
});

// Show the result
document.body.appendChild(canvas);

</SCRIPT>
Expand Down
4 changes: 4 additions & 0 deletions examples/example_projective_2d.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<BODY>
<SCRIPT>

// Create a dual projective 2D algebra with some basic operations

var P2 = Algebra({metric:[0,1,1],basis:['1','e0','e1','e2','e12','e20','e01','e012']}).inline(function(){
this.point = (X,Y)=>1e12+X*1e20+Y*1e01;
this.join = (x,y)=>!(!x^!y); // union
Expand All @@ -16,6 +18,8 @@
})();


// Use the graph function to display a labeled set of elements.

document.body.appendChild(P2.graph(P2.inline(function(){
var O=P2.point(-1,-1), X=P2.point(1,-1), Y=P2.point(-1,1),z=P2.join(Y,X),o=-1*P2.ortho(O,z),rot=this.rotor(0.3,O);
return {
Expand Down

0 comments on commit bafdb40

Please sign in to comment.