It is known that individual opinions on different policy issues often align to a dominant ideological dimension (e.g. left vs. right) and become increasingly polarized. We provide an agent-based model that reproduces these two stylized facts as emergent properties of an opinion dynamics in a multi-dimensional space of continuous opinions. The mechanisms for the change of agents opinions in this multi-dimensional space are derived from cognitive dissonance theory and structural balance theory. We test assumptions from proximity voting and from directional voting regarding their ability to reproduce the expected emerging properties. We further study how the emotional involvement of agents, i.e. their individual resistance to change opinions, impacts the dynamics. We identify two regimes for the global and the individual alignment of opinions. If the affective involvement is high and shows a large variance across agents, this fosters the emergence of a dominant ideological dimension. Agents align their opinions along this dimension in opposite directions, i.e. create a state of polarization.