```5.1.  COORDINATE SYSTEMS AND BASIS VECTORS

An absolute 3-dimensional cartesian coordinate system (x,y,z) defines all
atom coordinates of a cluster (CLUSTER session) as well as the elementary
cell and the lattice periodicity vectors R1,R2,R3 of a periodic structure
where R1,R2,R3 form a right-handed system (LATTICE session). All lattice
basis vectors of non-primitive lattices refer to points inside the elementary
cell spanned by R1,R2,R3. The system (x,y,z) is also used to define viewing
directions for graphical and numerical output of atom clusters.

In order to build net planes defined by Miller indices (h k l) in a LATTICE
session the original lattice vectors R1, R2, R3 are transformed linearly to
yield R1', R2', R3' where R1' and R2' are parallel to the (h k l) net planes
with R1' denoting the smallest length between equivalent atoms and R3'
forming a positive scalar product with the lattice plane normal vector En.

All atom coordinates of a lattice section (LATTICE session) are described by
an internal cartesian coordinate system (X, Y, Z) which is also used to
define viewing directions for graphical and numerical output of lattice
sections. In this system the transformed basis R1', R2', R3' is given by

R1' = a ( 1, 0, 0 )
R2' = b ( cos(ph1), sin(ph1), 0 )
R3' = c ( sin(th)*cos(ph2), sin(th)*sin(ph2), cos(th) )

with

a = |R1'|,  b = |R2'|,  c = |R3'|,  |En| = 1

ph1 = angle(R1',R2'),  th = angle(R3',En),  ph2 = angle(R3'-(R3'*En)En,R1')

Alternative layer periodicities modeling restructured layers are defined by
2x2 matrix transformations. The planar basis vectors R1'', R2'' of the
restructured layer are given as

R1'' = M11 * R1' + M12 * R2'
R2'' = M21 * R1' + M22 * R2'            .

where R1', R2' define the original layer periodicity. Separate lattice basis
vectors can be assigned to a layer in order to allow layer restructuring in
the most general case. For further details consult Sec. 6.2.5 and references
given at the end of this manual.

All internal computations are based on reciprocal Bravais lattice vectors
corresponding to R1, R2, R3. For cubic structures (fcc, bcc and composite
structures based on fcc, bcc) BALSAC can accept Miller indices both in the
commonly used simple cubic and in Bravais notation, see Sec. 6.2.1.

In parallel projection (PERSP = 0, >> 1) atoms described by (X, Y, Z)
(LATTICE session) or (x, y, z) (CLUSTER session) are projected on to the
viewing plane defined by its normal vector of direction THETA, PHI

p = (sin(THETA)*cos(PHI), sin(THETA)*sin(PHI), cos(THETA))

The x axis of the viewing plane is defined by (En x p) x p (En is the lattice
plane normal vector (LATTICE session) or vector (0,0,1) (CLUSTER session))
and the y axis points along (En x p). If p is parallel/antiparallel to En
then x, y coincides with the internal coordinate directions X, Y. For
graphics output with a rotation angle ROT = 0 the x direction is vertical
pointing downwards and the y direction is horizontal pointing to the right on
the screen. For non-zero rotation angles the plot coordinates are rotated
clock-wise about the screen origin (center of the screen). The plot
coordinates are enlarged/reduced by the optional magnification factor MAGNF.

In central projection the projection plane stands perpendicular to the
viewing direction at a distance R from the origin which is placed by default
at the center of the crystal section or cluster and where R denotes the
radius of the smallest sphere about O enclosing the section (see figure).

|
|   crystal section
|     or cluster
|        -------------           viewing
|      / / / / / / / /           direction
|     / / / / / / / /
|    / / / O / / / /            <----- <X  viewer
|   / / / /:/ / / /                     :
|  / / / / : / / /                      :
| ---------:----                        :
|... R.....:                            :
|................. persp*R .............:
|

projection plane

The viewer <X is assumed at a distance persp*R from the projection plane
where persp > 0 can be chosen freely with the view option. For perspective
factors persp < 1 some atoms may sit behind the viewer and will not show in
plots. The projection origin O can be repositioned with the view option
whereas the distance definitions R, persp*R remain always unchanged.

When viewing angles are changed incrementally (using fast plot keys, see
Secs. 6.2.9, 6.3.7) the visual movement of the displayed section will proceed
in different directions depending on the rotation angle ROT. For ROT < 180
pressing [arrow right] (increasing PHI by DPHI and repeating the plot) will
move the background part of the section to the right while ROT > 180 moves
the background part to the left. Pressing [arrow up/down] leads also to
opposite visual movements for ROT < 180 and > 180.