# Setting directional cosines

Hello,

I am a little unclear on how the directional cosines are set to create a new Simple ITK image. I understand that they should be in row major order. Is this correct: If we take a 2D example, the unit vector along a row (across columns) would go first and the unit vector along a column (across rows) would go second? If so, I am a bit confused with the 2D brain image example in the fundamental concepts guide. There, when the image is not tilted (the one on the right), the directional cosines are (1,0,0,1), which is essentially (direction cosine along a row, directional cosine along a column), i.e., (x axis direction, y axis direction). But when the image is tilted (left image), I would think the cosines would be (0.7, 0.7, -0.7, 0.7). I.e., the direction along row is now (0.7, 0.7) and direction along column is (-0.7, 0.7). This is different from what is written on the webpage, which is (0.7, -0.7, 0.7, 0.7). Can you kindly clarify if I am missing something here?

Also, in 3D, just to confirm, the row major order of cosines would be the following, correct?
(directional cosine along increasing slice direction, directional cosine along row direction (across columns), directional cosine along column direction (across rows))

Thank you!

Yeah, I think that’s a bug in the documentation. Here’s the test code that I made:

``````import SimpleITK as sitk

t = sitk.Euler2DTransform()
t.SetAngle(0.785398)   # 45 degrees
print(t.GetMatrix())
``````

and here’s the output:

``````(0.7071068967259817, -0.7071066656470943, 0.7071066656470943, 0.7071068967259817)
``````

Hello @Krishna_Nanda,

This isn’t a bug in the documentation. Please add the following line to @dchen’s code snippet and look at the matrix:

``````print(t)
``````