Closed stigmergic closed 3 years ago
Actually worse: there is also heading which is in degrees, but clockwise from due north. So there are really two kinds of degrees: CCW & CW!
Obviously there are utils to go between heading & degrees and radians
But: Stephen and I were working on attempting to deal with this when the desire to have real 3D vs 2.5D (which we already had). So this bumped the heading, degrees (ccw & cw) vs radians solution and I've never gotten back to it. (BTW: I did do a few experiments, thus the 2D heading() function Benny used. To be honest, I always thought of heading as generally meaning "direction" so mistakenly used it incorrectly for a while, but then corrected this as part of our look at all this)
After todays chat, including Moohit Dubey, the JavaScript / AgentScript boundary came up again.
I think this is pretty important. My personal preference is using radians and the euclidean absolute usage rather than NL heading. Annoying but much less confusing.
Oh, and one other thing: Object3D. It's Three's 3D geometry module and is the heart of our Turtle3D.js. You may want to take a look. Naturally it's euclidean/radians.
It would be easy to add to/from degrees/radians utils in Turtle.js and Turtle3D.js.
And we could even use "heading" as "direction" .. i.e. euclidean/radians. It depends if students are aware of the highly specific use of heading, rather than the more general use.
The issue with two degrees, CW & CCW is real, btw.
Currently, there is a "rotate()" method and left/right use it. In Turtle.js (2d)
Rotate includes a normalization keeping theta between 0-2PI, and right/left use it in relative angles:
rotate(rad) { this.theta = util.mod2pi(this.theta + rad) } right(rad) { this.rotate(-rad) } left(rad) { this.rotate(rad) }
But notice the right/left would be off by a sign in heading coords! Also, headings degrees are normalized -180, 180 while euclidean is 0, 2PI.
So we have TWO problems: radians vs degrees, and heading (degrees CW from north)
The JS Math module, Three, and most JS libraries use euclidean radians.
And, if APIs do use degrees, they are euclidean rather than heading (0 north, CW). P5js, for example, in degree mode.
I'm closing this for now, see #28 for a broader issue.
If you do, you better make it really really clear. Like, put
degree
orradian
in the function name.