|
1 | 1 |
|
2 | 2 | suite('p5.Vector', function() { |
| 3 | + var RADIANS = 'radians'; |
| 4 | + var DEGREES = 'degrees'; |
3 | 5 |
|
4 | 6 | var myp5 = new p5(function( p ) { |
5 | 7 | p.setup = function() {}; |
@@ -84,8 +86,35 @@ suite('p5.Vector', function() { |
84 | 86 | assert.equal(v.z, 0); |
85 | 87 | }); |
86 | 88 | }); |
87 | | -}); |
88 | 89 |
|
| 90 | + suite('p5.prototype.rotate() RADIANS', function() { |
| 91 | + setup(function() { |
| 92 | + myp5.angleMode(RADIANS); |
| 93 | + v = myp5.createVector(0, 1); |
| 94 | + }); |
| 95 | + |
| 96 | + test('should have x, y, z rotated to 0, -1, 0 (RADIANS)', function() { |
| 97 | + v.rotate(Math.PI); |
| 98 | + assert.closeTo(v.x, 0, 0.001); |
| 99 | + assert.closeTo(v.y, -1, 0.001); |
| 100 | + assert.closeTo(v.z, 0, 0.001); |
| 101 | + }); |
| 102 | + }); |
| 103 | + |
| 104 | + suite('p5.prototype.rotate() DEGREES', function() { |
| 105 | + setup(function() { |
| 106 | + myp5.angleMode(DEGREES); |
| 107 | + v = myp5.createVector(0, 1); |
| 108 | + }); |
| 109 | + |
| 110 | + test('should have x, y, z rotated to 0, -1, 0 (DEGREES)', function() { |
| 111 | + v.rotate(180); |
| 112 | + assert.closeTo(v.x, 0, 0.001); |
| 113 | + assert.closeTo(v.y, -1, 0.001); |
| 114 | + assert.closeTo(v.z, 0, 0.001); |
| 115 | + }); |
| 116 | + }); |
| 117 | +}); |
89 | 118 |
|
90 | 119 | // describe('set()', function() { |
91 | 120 | // describe('with p5.Vector', function() { |
|
0 commit comments