%%                        MTEX Workshop 2020
%
%%                         Exercises Day 1
%
% * The exercises will be discussed during the first exercise session.
%
% * You might want to go through it before to check what you can do for
% your own.
%
% * The main purpose of the exercises is to get used to the syntax of MTEX
% and learn some, maybe not so well known commands.
%
% * Try to make to figure nice. Adjust color, linewidth, ... and ask if you
% want to know about the options.
%
% * Try to use tab completion as much as possibel. It prevents you of
% missspelling commands and options.
%
% * The exercises contain hints for useful commands. Type

help commandName

% into the command window to get additional information to this command
%
% * Exercises marked by an (*) might be a little bit more complicated.
% 
% 
%% Exercise 1 - Matlab Basics
%
%% a)
% Generate the list of squares of all numbers from 1 to 20.
%
% useful commands: .*, .^



%% b)
% Single out all even square numbers.
%
% useful commands: iseven, 1:2:end



%% c)
% Compute the sum of the reciprocals of all square integers. Is there a
% limit if the numbers go to infinity?
%
% useful command: sum, 1./n




%% d*)
% Compute the alternating sum of the reciprocals of the even and odd
% squares: 1/1^2 - 1/2^2 + 1/3^2 - 1/4^2 + 1/5^2 .....
% What is the limit? Hint: it is a multiple of pi^2.




%% Exercise 2
%
%% a)
% Visualize the two vectors u1 = (1,0,2) and u2 = (2,3,-1) and determine
% the angle between these two vectors in degree.



%% b)
% Find a third vector u3 that is orthogonal to u1 and u2.
%
% useful command: cross





%% c)
% Normalize u1, u2, u3 such that they form an orthonormal basis. How can we
% check that u1, u2, u3 form a right handed basis?
%
% useful command: det




%% d)
% Find the active rotation |rot| that maps u1 to v1 and u2 to v2. Verify
% your result by computing the angle between |rot*u1| and |v1| and |rot*u2|
% and |v2|
%
% useful command: rotation.map



%% e)
% Compute its rotational axis and its rotational angle of the rotation
% defined in d).


%% f)
% Could we have replaced v2 by (1,1,-1)? Why not?




%% e)
% Find an approximate rotation that maps u1 onto v1 and u2 onto v2 =
% (1,1,-1). Visualize the result and determine the misfit.
%
% useful command: rotation.fit, scatter3d




%% Exercise 3
%
%% a)
% Define the rotation with the Euler angles (10, 20, 30) without using the
% command rotation.byEuler and check you result.
%
% useful comand: rotation.byAxisAngle




%% b)
% Visualize this rotation in 3d Euler angle space.



%% c)
% Visualize the rotation in Euler angle sections.
%
% useful commands: plotSection



%% Exercise 4
%
%% a)
% Generate two random rotations rot1 and rot2 and visualize them in a three
% dimensional axis angle plot and in the three dimensional Euler angle
% plot.
% Make a nice plot with legend and filled plot markers.



%% b)
% Determine the misrotation angle delta between rot1 and rot2.



%% c)
% Determine a rotation rotM such that misrotation angles between rotM and
% rot1 and rotM and rot2 are both delta/2. Highlight rotM in the two plots
% of a) as a black square.
%
% useful commands: be creative, there are many solutions :)





%% d*)
% Find a list rotL of 101 rotations that gradually change from rot1 to
% rot2, i.e., rotL(1) = rot1, rot(101) = rot2; rotL(51) = rotM. Visualize
% this line.
%
% useful commands: linspace


%% e*)
% Determine as many rotations rotP as posible such that the distances
% between (rotP,rot1) and (rotP,rot2) are equal.
%
% useful commands: vector3d/perp



%% f*)
% Recreate the above plot in Euler angle space and Rodrigues Frank space.

%% Exercise 5
%
%% a)
% Generate random pairs of rotations with misrotation angle delta = 20
% degree.




%% b) 
% Plot these pairs of rotations as lines in a three dimensional Euler angle
% plot-
%
% useful commands: line



%% c) 
% Plot these pairs of rotations as lines in a three dimensional axis angle
% plot.

%% Exercise 6
%
% Consider the following Quartz crystal

cs = crystalSymmetry.load('quartz.cif')

cS = crystalShape.quartz

plot(cS,'colored')

%% a)
% Visualize the plane normals of the positive rhomboedron (1,0,-1,1), the
% negative rhomboedron (0,1,-1,1) and left tridiagonal bipyramid (1,1,-2,1)
% in a equal angle projection. Colorize them as in the crystal shape plot
% and label them nicely.
%
% useful commands: Miller
% hint: use the option upper to plot only the upper hemisphere



%% b)
% Visualize the traces of the coresponding planes.
%
% useful command: circle 



%% c)
% Determine all angles between the above planes.



%% d)
% Determine the directions of the intersections between the above planes
% and visualize them in a spherical projection.



%% Exercise 7
% 
%% a) 
% Generate a symmetry group that consist of three fold axis in direction
% (111) and a two fold axis perpendicular to it. Visualize the symmetry
% group using the command plot.
%
% useful commands: rotation.byAxisAngle, crystalSymmetry.byElements



%% b)
% Turn the above symmetry into a Laue group by adding the inversion and
% plot it again.
%
% useful commands: crystalSymmetry/add, rotation.inversion



%% c)
% Add to the above symmetry a four fold axis in direction (001). Which
% symmetry group do we obtain?



%% d)
% Verify, that a mirroring at a plane with normal (111) is nothing else
% then a rotation around the axis (111) about 180 degree followed by an
% inversion.
%
% useful commands: reflection



%% Exercise 8
%
%% a) 
% Define trigonal crystal symmetry 321 and a random crystal direction.
% Compute all symmetrically equivalent crystal directions without using the
% command symmetrise and check that your result is correct.
%
% useful commands: Miller.rand





%% b)
% Compute the angles between all symmetrically equivalent directions
%
% useful commands: angle, angle_outer, symmetrise
% useful options: noSymmetry



%% c) 
% Find a crystal direction which has exactly two symmetrically equivalent
% directions with respect to the symmetry 321
%
% useful commands: unique
% useful options: noSymmetry




%% d) 
% Find a crystal direction which has exactly three symmetrically equivalent
% directions with respect to the symmetry 321




%% e)
% What are the common symmetries of the point groups 321 and m-3?
% Do the common symmetries again form a point group?
%
% useful commands: symmetry/disjoint



%% Exercises 9
%
% Define a crystal symmetry such that (011) is not parallel to {011}.
% Verify this using the command angle. What is the highest symmetry you
% could have used?



