pglyph3D: Plot a 3D body on an existing graphic

View source: R/pglyph3D.R

pglyph3DR Documentation

Plot a 3D body on an existing graphic

Description

rotates a body in 3D and plots projection on existing plot

Usage

pglyph3D(aglyph, M = diag(1, nrow = 4), M2 = diag(1, nrow = 4),
         anorms = list(), zee = c(0, 0, 1), col = "white", border = "black")

Arguments

aglyph

glyph structure describing the vertices and normal vectors of a 3D body

M

rotation matrix 1

M2

rotation matrix 2

anorms

up vector

zee

up vector

col

coor of body

border

color of border

Details

Hidden sides are removed and phong shading is introduced to create 3D effect.

The input consists of an object defined by a list structure, list(aglyph, anorm) where aglyph is list of 3D polygons (faces) and anorm are outward normals to these faces.

Value

Used for side effect on plots

Note

For unusual rotations or bizarre bodies, this routine may produce strange looking shapes.

Author(s)

Jonathan M. Lees <jonathan.lees@unc.edu>

References

Rogers and Adams, 1990, Mathematical Elements for Computer Graphics, McGraw-Hill, 611p.

See Also

Z3Darrow, ROTX, ROTY, ROTZ

Examples


### create the 3D object
len = .7
basethick=.05
headlip=.02
headlen=.3

####  create a 3D glyph structure
aglyph = Z3Darrow(len = len , basethick =basethick , headlen =headlen ,
headlip=headlip )

#### define the up vector 
myzee = matrix(c(0,0,1, 1), nrow=1, ncol=4)

##### set rotation angles:
gamma =12
beta =39
alpha = 62

########  set up rotation matrix
R3 = ROTZ(gamma)

R2 = ROTY(beta)

R1 = ROTZ(alpha)

###  create rotation matrix
M =      R1  

M2 =       R1  


plot(c(-1,1), c(-1,1))

 pglyph3D(aglyph$aglyph, anorms=aglyph$anorm  , M=M, M2=M2, zee=myzee ,
col=rgb(.7, 0,0) )




RFOC documentation built on Sept. 8, 2023, 6:12 p.m.