Learn R Programming

orientlib (version 0.7.2)

boat3d: Draw boat glyphs for orientation data

Description

Draws a stylized sailboat to represent an orientation.

Usage

boat3d(orientation, x = 1:length(orientation), y = 0, 
       z = 0, scale = 0.25, col = 'red', add = FALSE, box = FALSE, axes = TRUE,
       graphics = c('djmrgl', 'rgl', 'scatterplot3d'), ...)

Arguments

orientation
An orientation object to be shown.
x, y, z
Coordinates where boats should be shown.
scale
Size of boats
col
Colour of boats
add
Context in which to continue drawing, or FALSE to clear first.
box
Whether to draw a box around the plot
axes
Whether to draw axes
graphics
Which graphics package to use
...
Additional graphics parameters; see Details below

Value

  • A djmrgl handle for the graphics display, a current plot number for rgl, or a scatterplot3d drawing context. In any case, an attribute named graphics is added to indicate the drawing device type.

Details

For the identity orientation, the sailboats will be shown upright. Other orientations are shown as rotations of this glyph. The (x,y,z) coordinate appears in the middle of the sail, at the top of the gunwales of the boat. If either the djmrgl or rgl package is installed, it will be used to draw solid faces on the boats which can be moved by the user. If not, but the scatterplot3d package is installed, it will be used to draw fixed wireframe boats. This search order can be changed by modifying the graphics parameter. Additional graphics parameters may be passed. If djmrgl graphics is used, then these are passed to par3d before the plotting is done; if scatterplot3d is used, these are passed to the scatterplot3d function (and ignored when adding to an existing plot). Extra parameters are not passed to rgl. To add to a scatterplot3d plot, you must pass the return value from the initial plot as the value of add. See the orientlm function for an example.

Examples

Run this code
x <- eulerzyx(psi=c(0,pi/4,0,0), theta=c(0,0,pi/4,0), phi=c(0,0,0,pi/4))

# Need a 3D renderer; assume scatterplot3d, but others could be used

s <- boat3d(x, 0:3, axes = FALSE, graphics = 'scatterplot3d')
text(s$xyz.convert(0:3, rep(-0.5,4), rep(-0.5,4)), 
     label = c('Id','z','y','x'))
         
# if the djmrgl package is loaded, this code will work
         
boat3d(x, 0:3, axes = FALSE)
axis3d('yz',at=0:3,labels=c('Id','z','y','x'))

# if the rgl package is loaded, this code will work

boat3d(x, 0:3, axes = FALSE, graphics = 'rgl')
rgl.bbox(xat=0:3,xlab=c('Id','z','y','x'),yat=1,zat=1,color='grey')

Run the code above in your browser using DataLab