0

Goal:

My goal is to rotate the white line as you change the slider value. But it doesn't work! Please assist. Image: Rotation Slider

Effort:

Things I've tried:

  • Drawing white line as a curve and rotating the curve with rotate method
  • Drawing white line as an arrow and rotating arrow with rotate method
  • Establishing a frame f and appending white line to frame and rotating the frame
  • Using a for loop to continually update the angle of the line.

Please assist.

Code: Rotation Slider

Relevant Lines:

c = curve(pos = [vector(-10,0,0),vector(10,0,0)], radius = 0.3)

def setspeed(s):
    wt.text = '{:1.0f}'.format(s.value)
    
sl = slider(min=0, max=360, step = 10, value = 45, bind=setspeed)

wt = wtext(text='{:1.2f}'.format(sl.value))

c.rotate(angle=sl.value, axis = vector(0,0,1), origin = vector(0,0,0))
2
  • I'm no expert with GlowScript, however, I would recommend checking that the c.rotate() function is being called continuously and that sl.value is being updated. Commented Nov 12, 2020 at 1:06
  • I'll comment that for GlowScrippt VPython questions it's better to post to the GlowScript VPython forum, where there are many more GlowScript VPython users who will see your question than if you post to stackoverflow: groups.google.com/g/glowscript-users Commented Jan 2, 2021 at 19:54

1 Answer 1

1

It looks like the problem is that the rotate function expects angles in radians, not degrees, so you would say angle=radians(sl.value).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.