gl 3d rotation of parent child shapes

Derek Franz's icon

hope someone with trig or linear algebra knowledge can clarify this for me
seems like for years Ive stumbled on deriving the xyz cordinates of a
cylinder's tip so I can bind it seemlessly to other shapes as arms or
tendrils. this patch shows my appraoch to the problem and can be aded to a
gl.sketch environment, it uses jasch's rotatexyz to attempt to bind a sphere
to a cylinders end, I just cant get it to bind when xy and z are actively
rotating, I use a half black half white texture to make the cylinder half
invisible for simplicity, the shape orient command is scaled and moded into
pi phases
it seems like the shape orient and the xyzrotate just arn't in the same
coordinate system, and that there is some constant attenuation that needs to
be made to get them to agree,
siggraph site has these equations but I dont know how to translate math
matri in my head anymore let alone into max, can someone drop me a patch or
mod mine so I can jump this hurdle get back into the art of things

Z-axis rotation is identical to the 2D case:
x' = x*cos q - y*sin q
y' = x*sin q + y*cos q
z' = z

( cos q sin q 0 0)
Rz (q) = (-sin q cos q 0 0)
( 0 0 1 0)
( 0 0 0 1)

X-axis rotation looks like Z-axis rotation if replace:
X axis with Y axis
Y axis with Z axis
Z axis with X axis
So we do the same replacement in the equations:
y' = y*cos q - z*sin q
z' = y*sin q + z*cos q
x' = x

(1 0 0 0)
Rx(q) = (0 cos q sin q 0)
(0 -sin q cos q 0)
(0 0 0 1)

Y-axis rotation looks like Z-axis rotation if replace:
X axis with Z axis
Y axis with X axis
Zaxis with Y axis
So we do the same replacement in equations :
z' = z*cos q - x*sin q
x' = z*sin q + x*cos q
y' = y

(cos q 0 -sin q 0)
Ry(q) = (0 1 0 0)
(sin q 0 cos q 0)
(0 0 0 1)

Max Patch
Copy patch and select New From Clipboard in Max.


Joshua Kit Clayton's icon

Hi Derek,

The easy way to handle this is use the transform matrix rather than
calculating the 4x5 modelview matrix by hand. Please see the OpenGL
Redbook (html/pdf of v1.1 available at www.opengl.org), or the
various online tutorials on OpenGL modelview matrix manipulation for
more information. You can then avoid having to calculate the 4x4
modelview matrix values explicitly. The important sketch commands you
will want to familiarize yourself with are:

glmatrixmode
glpushmatrix
glpopmatrix
gltranslate
glscale
glrotate

Hope this points you in the right direction.

-Joshua