pglyph3D: Plot a 3D body on an existing graphic

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/pglyph3D.R

Description

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

Usage

1
2
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 <[email protected]>

References

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

See Also

Z3Darrow, ROTX, ROTY, ROTZ

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
### 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 Jan. 20, 2018, 9:46 a.m.