about mouse position

19 views
Skip to first unread message

林靜得

unread,
Jul 30, 2018, 5:05:19 AM7/30/18
to VPython-users
hello
i am using function of mouse position. when i click on the right side , it returns a position,which has a negative value of x coordinate.why?
btw, scene.range means that the distance from center to right or left.why will i have a bigger absolute value than range when i click on right boundary?
thx
from vpython import *
scene=canvas()
sphere(pos=vector(0,0,17))
scene.camera.axis=vector(0,0,17)
scene.camera.pos=vector(0,0,0)
ev=scene.waitfor('click')
if ev.event=='click':
    temp = scene.mouse.project(normal=vector(0,0,1),point=vector(0,0,0))
    print(scene.mouse.pos)
    print(temp)


Steve Spicklemire

unread,
Jul 30, 2018, 6:14:28 AM7/30/18
to vpytho...@googlegroups.com, Steve Spicklemire
I think that since you are pointing the camera in the +z direction, your point of view is out of the page. From this perspective the “left” is the negative x direction.

From the docs:

range The extent of the region of interest to the left or right of center. Setting range to 10 means that scene.center.x+scene.range will be at the right edge of a square window. A sphere of radius 10 will fill the window. A cubical box whose half-width is 10 will overfill the window, because the front of the box in 3D appears larger than the xy plane passing through scene.center, unless the field of view is very small.

Perhaps your canvas isn’t square? Try: scene=canvas(width=400,height=400)

good luck!
-steve
> --
> You received this message because you are subscribed to the Google Groups "VPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Steve Spicklemire

unread,
Jul 30, 2018, 7:26:47 AM7/30/18
to vpytho...@googlegroups.com, Steve Spicklemire
Of course I meant “right” is negative x. Sorry.

-steve

林靜得

unread,
Jul 31, 2018, 12:14:39 AM7/31/18
to VPython-users
First thank for your answer.I know why the "right" will be negative.
But why will the upper bound be the scene l.range? It should be left or right? Right?

Bruce Sherwood

unread,
Jul 31, 2018, 6:57:16 AM7/31/18
to VPython-users
I'm not sure I understand your question, since i don''t know the meaning of l.range, but note that the default size of a canvas is 640 by 400, so the maximum y coordinate is smaller than the maximum x coordinate.

Bruce
Reply all
Reply to author
Forward
0 new messages