Trying to understand 4d vectors and matrix

Hello, I know this neccessarily doesnt have much to do with JME, however, it does have to do with learning shader language which i shall use in conjunction with jme.

now, i understand 3d vectors and 3d matrix pretty well, however, i am confused of the structure/use/utilization  of this 4th dimension

if i am correct they look like

XYZW - 4D Vector

    4D matrix


X  - - - -

Y  - - - -

Z  - - - -

W  - - - -

am I correct on this? how does the W interact which such objects?

Thank you.

A xyzw matrix / quaternion defines a (relative) rotation. The first three values are the axis and the w value is the rotation around that axis.