  The intrinsic alignment of galaxy shapes with the large-scale density field
is a contaminant to weak lensing measurements, as well as being an interesting
signature of galaxy formation and evolution (albeit one that is difficult to
predict theoretically). Here we investigate the shapes and relative
orientations of the stars and dark matter of halos and subhalos (central and
satellite) extracted from the MassiveBlack-II simulation, a state-of-the-art
high resolution hydrodynamical cosmological simulation which includes stellar
and AGN feedback in a volume of $(100{h^{-1}\mathrm{Mpc}})^3$. We consider
redshift evolution from $z=1$ to $0.06$ and mass evolution within the range of
subhalo masses, $10^{10} -6.0 \times 10^{14.0}{h^{-1}M_{\odot}}$. The shapes of
the dark matter distributions are generally more round than the shapes defined
by stellar matter. The projected root-mean-square (RMS) ellipticity per
component for stellar matter is measured to be $e_\text{rms} = 0.28$ at $z=0.3$
for $M_{subhalo}> 10^{12.0}{h^{-1}M_{\odot}}$, which compares favourably with
observational measurements. We find that the shapes of stellar and dark matter
are more round for less massive subhalos and at lower redshifts. By directly
measuring the relative orientation of the stellar matter and dark matter of
subgroups, we find that, on average, the misalignment between the two
components is larger for less massive subhalos. The mean misalignment angle
varies from $\sim 30^{\circ}-10^{\circ}$ for $M \sim 10^{10} - 10^{14}
{h^{-1}M_{\odot}}$ and shows a weak dependence on redshift. We also compare the
misalignment angles in central and satellite subhalos at fixed subhalo mass,
and find that centrals are more misaligned than satellites. We present fitting
formulae for the shapes of dark and stellar matter in subhalos and also the
probability distributions of misalignment angles.
