BruceSherwood/glowscript

rotate destroys curves

Closed this issue · 2 comments

Example (1)

f = frame()
hor = curve(frame=f, pos=[vector(-1, 0, 0), vector(1, 0, 0)], radius=0.2)
ver = curve(frame=f, pos=[vector(0, -1, 0), vector(0, 1, 0)], radius=0.2)
f.rotate(angle=1)

Desired and Expected Behavior (standard python)

The curves rotate in the obvious way.

Observed behavior (browser-based system)

  • Frames are not implemented.
  • Compound does not support curves
  • Replacing the curve by an extrusion doesn't work, because for some reason extrusions require the extrusion-path to be closed.
  • Calling the rotate() method on the curve object fails in an even stranger way:

Example(2)

hor = curve(pos=[vector(-1, 0, 0), vector(1, 0, 0)])
ver = curve(pos=[vector(0, -1, 0), vector(0, 1, 0)])
ver.rotate(angle=0)
print(hor.pos)
print(ver.pos)

In standard python, this would throw an exception; for some reason the curve object does not implement a .rotate method.

In the browser-based system, it does not throw an exception; it just causes the object to disappear from the canvas. It trashes the object's .pos property.

Suggestions:

  • In standard python and in browser-based python, it would be nice for curve objects to directly support a rotate method. It's not tricky; just rotate each vector in the pos list.
  • In the browser, frames would be nice. Compound curves would be nice. Usable extrusions would be nice.
  • More generally, a convenient way of rotating curve-like objects would be nice.
  • Failing that, it should throw an exception with an informative error message.

It's an oversight that curve.rotate isn't implemented, and it is intended to be able to compound a curve. There is however a way to rotate a GlowScript curve:

c = curve(pos=[vector(-1,-1,0), vector(1,-1,0), vector(0,1,0)], color=color.cyan)
scene.waitfor('click')
c.axis = vector(1,0.3,0)

Similarly, you can change the origin and size, as described in the GlowScript VPython Help. This is pretty different from classic VPython. However, something's not right because the lighting doesn't behave correctly in some of these cases.

Extrusion: Under development. The initial release requires closed paths because a tessellation algorithm is needed to render the ends. I do now have such an algorithm, which can handle any outline and (at most) one hole of any outline:

http://www.glowscript.org/#/user/Bruce_Sherwood/folder/My_Programs/program/Tessellate2

Yes, frames aren't implemented. At the start of the GlowScript project Scherer was skittish about frames, for nontrivial reasons associated with the GPU environment, but I agree that something like this is desirable and should be reconsidered.

curve rotate bug fixed.