git @ Cat's Eye Technologies Erratic-Turtle-Graphics / 396269e
Clean up degrees vs radians. Chris Pressey 2 years ago
2 changed file(s) with 5 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
186186 turtle.moveBy(instr[1]);
187187 break;
188188 case "rt":
189 turtle.rotateByDeg(instr[1]);
189 turtle.rotateBy(instr[1]);
190190 break;
191191 case "lt":
192 turtle.rotateByDeg(-1 * instr[1]);
192 turtle.rotateBy(-1 * instr[1]);
193193 break;
194194 case "setxyp":
195195 turtle.setXYProportional(instr[1], instr[2]);
2121 this.moveError = 0.0;
2222 };
2323
24 /* theta is in radians */
24 /* theta is in degrees */
2525 this.setTheta = function(theta) {
2626 this.theta = theta;
2727 this.dx = Math.cos(theta);
2828 this.dy = Math.sin(theta);
29 };
30
31 this.setThetaDeg = function(theta) {
32 this.setTheta(theta * DEG);
3329 };
3430
3531 this.setXYProportional = function(xp, yp) {
5248 this.moveError += dmerr;
5349 };
5450
55 /* dtheta is in radians */
51 /* dtheta is in degrees */
5652 this.rotateBy = function(dtheta) {
5753 var error = (Math.random() - 0.5) * this.rotateError;
58 this.setTheta(this.theta + dtheta + error);
59 };
60
61 this.rotateByDeg = function(dtheta) {
62 this.rotateBy(dtheta * DEG);
54 this.setTheta(this.theta + (dtheta * DEG) + error);
6355 };
6456
6557 this.moveBy = function(units) {