rgl.user2window {rgl}R Documentation

Convert between rgl user and window coordinates

Description

This function converts from 3-dimensional user coordinates to 3-dimensional window coordinates.

Usage

rgl.user2window(x, y, z, projection = rgl.projection())
rgl.window2user(x, y, z = 0, projection = rgl.projection())
rgl.projection()

Arguments

x, y, z Input coordinates
projection The rgl projection to use

Details

These functions convert between user coordinates and window coordinates.

Window coordinates run from 0 to 1 in X, Y, and Z. X runs from 0 on the left to 1 on the right; Y runs from 0 at the bottom to 1 at the top; Z runs from 0 foremost to 1 in the background. rgl does not currently do clipping, so values of Z that are negative or bigger than 1 are possible.

Value

The coordinate conversion functions produce a matrix with columns corresponding to the X, Y, and Z coordinates.
rgl.projection() returns a list containing the model matrix, projection matrix and viewport. See par3d for more details.

Author(s)

Ming Chen / Duncan Murdoch

See Also

select3d

Examples

rgl.clear()
points3d(rnorm(100), rnorm(100), rnorm(100))
if (interactive() || !.Platform$OS=="unix") {
# Calculate a square in the middle of the display and plot it
square <- rgl.window2user(c(0.25, 0.25, 0.75, 0.75, 0.25), c(0.25, 0.75, 0.75, 0.25, 0.25), 0)
lines3d(square[,1], square[,2], square[,3])
}

[Package rgl version 0.65 Index]