In this tutorial you will learn how to do basic things on the IPLT command line.

The IPLT command line is built on top of Python. If you want to get more information on any object, function or class, the python help command may be useful.

```
#import classes from geom module
from ost.geom import *
# get list of methods of Rotation3
help(Rotation3)
# get help for method GetPsi
help(Rotation3.GetPsi)
```

IPLT has built-in support for vectors in 2,3 and 4 dimension. They are called Vec2, Vec3 and Vec4 respectively. You can use the vector classes like in a math formula: You can add them together, multiply them by scalar values or calculate the inner and outer product. This short code snippet gives an idea of how you can use vectors.

```
from ost.geom import *
a=Vec2(1,0)
b=Vec2(0,1)
# print the vectors
print a,b
# create a new vector by using components of both a and b.
# The components of a vector can be accessed by using the
# array subscript notation:
c=Vec2(a[0],b[1])
# print length of vector a and b
print Length(a), Length(b)
# calculate dot (inner) product
print Dot(a,b)
# do some fancy calculation
d = a+2*b
print '%s+2*%s is %s' % (a,b,d)
```

Linear transforms such as scaling, rotation of vectors can be achieved easily.

Rotations are usually carried out using quaternions or rotation matrices. There are several helper classes in IPLT that encapsulate the logic of rotation.The Rotation3 class represents a rotation in 3D space defined by 3 Euler angles.

```
import math
# define rotation around x axis by 180 degress (PI radians)
rot=Rotation3(math.pi,0,0)
v=Vec3(0,1,0)
# rotate v by rot
print rot.GetRotationMatrix()*v
```

In two dimensions, the Rotate function can be used to rotate a vector by a certain amount

```
#rotate by 90 degrees (PI/2 radians)
print Rotate(Vec2(1,0),math.pi/2)
```

Uniform vector scaling can be accomplished by multiplication of the vector by a scalar factor. For non-uniform scaling you can use a 3x3 matrix with all but the main diagonal elements set to zero.

```
scale=Mat3(1.0,0.0,0.0,
0.0,2.0,0.0,
0.0,0.0,4.0)
print scale*Vec3(1,1,1)
```

While you are fitting a lattice to your diffraction
pattern *Fit lattice*, you would like to set the
angle between the first and second lattice vector to exactly 90 degrees.
You decide to do it on the command line. Your a-vector is fitting
perfectly, you only want to reorient the b-vector.

```
from ost.geom import *
from ost.io import LoadImage
import iplt.gui, math
# load the image and display it
image=LoadImage('marvelous_diff_pattern.tiff')
v=Viewer(image)
# add lattice overlay
lov=iplt.gui.LatticeOverlay()
v.AddOverlay(lov)
# get snapshot of lattice. note that all changes to lattice will not
# be reflected in the overlay. you need to call lov.SetLattice(l)
l = lov.GetLattice()
length_b=Length(l.GetSecond())
new_b = Normalize(Rotate(l.GetFirst(),math.pi/2))*length_b
l.SetSecond(new_b)
lov.SetLattice(l)
```