Vizard 7 » Command Index » Vizard objects » window » <window>.screenToWorld
7.6

<window>.screenToWorld

This command returns the line passing through the given screen coordinates

<window>.screenToWorld(  
[x,y]  
eye = viz.BOTH_EYE # keyword argument
mode = viz.WINDOW_NORMALIZED # keyword argument
)  
[x,y]
Screen coordinates in either normalized or pixel units, depending on the mode parameter.
eye = viz.BOTH_EYE
The eye to perform the operation on. Can be viz.BOTH_EYE, viz.LEFT_EYE, viz.RIGHT_EYE. If stereo mode is enabled, the command will automatically adjust the mouse coordinates for the specified eye.
mode = viz.WINDOW_NORMALIZED
One of the following modes:

Unit mode

viz.WINDOW_NORMALIZED

The coordinates passed to the function will be in normalized units, [0,1].

viz.WINDOW_PIXELS

The coordinates passed to the function will be in pixel units.

Remarks

This command will take normalized display coordinates and convert them into 3D coordinates of the sub-window.

Return Value

A Line object that contains the following attributes:

Attribute

begin

The begin point of the line.

end

The end point of the line.

length

The length of the line.

dir

The direction vector of the line.

matrix

The rotation matrix of the line.

Example

line = viz.MainWindow.screenToWorld(viz.mouse.getPosition())
print(line.begin)
print(line.end)

See also

<window>.worldToScreen
<window>.pick