# [vtkusers] reslice using an arbitrary orientation

Esmeralda Ruiz esmeralda.ruiz at alma3d.com
Mon Mar 25 19:27:29 EDT 2019

```Dear all

i update the question i wrote wrong the perpendicular making changes
double perpendicular = { vt,0,vt };

but i see that even i compute the perpendicular what it gives it is not
what i want. What i want is the slice that intersects in this orientation
not to create a new coordinate using this orientation. Any idea?

thanks

El lun., 25 mar. 2019 a las 20:08, zandarina (<esmeralda.ruiz at alma3d.com>)
escribió:

> Dear all
>
> I want to reslice a 3d volume computing the perpendicular
> between two points x and y. I compute the
> perpendicular berween point 1, point2 in x and y (z is the same for all
> points as the
> poins are obtained of one slice)
>
> And then i compute the perpendicular of x and y
> And i compute the rotation. And i get a blank image. I would like to
> cut the slice cutting through the perpendicular of those two points.
>
> I attach the code. Is there something wrong
>
> Any help?
>
>
>
>   double vt;
>         vt = pts2 - pts1;
>         vt = pts2 - pts1;
>         vt = pts2 - pts1; // it will be 0 as z is the same in all
> points
>         double perpendicular = { -vt,vt,0 };
>
>         double startPoint, endPoint;
>         startPoint = tar_cen;
>         startPoint = tar_cen;
>         startPoint = tar_cen;
>         endPoint = startPoint + perpendicular;
>         endPoint = startPoint + perpendicular;
>         endPoint = startPoint + perpendicular;
>
>         // Compute a basis
>         double normalizedX;
>         double normalizedY;
>         double normalizedZ;
>
>         // The X axis is a vector from start to end
>         vtkMath::Subtract(endPoint, startPoint, normalizedX);
>         //double length = vtkMath::Norm(normalizedX);
>         vtkMath::Normalize(normalizedX);
>
>         // The Z axis is an arbitrary vector cross X
>         double arbitrary;
>         arbitrary = vtkMath::Random(-10, 10);
>         arbitrary = vtkMath::Random(-10, 10);
>         arbitrary = vtkMath::Random(-10, 10);
>         vtkMath::Cross(normalizedX, arbitrary, normalizedZ);
>         vtkMath::Normalize(normalizedZ);
>
>         // The Y axis is Z cross X
>         vtkMath::Cross(normalizedZ, normalizedX, normalizedY);
>         vtkSmartPointer<vtkMatrix4x4> matrix =
>             vtkSmartPointer<vtkMatrix4x4>::New();
>
>         // Create the direction cosine matrix
>         matrix->Identity();
>         for (unsigned int i = 0; i < 3; i++)
>         {
>             matrix->SetElement(i, 0, normalizedX[i]);
>             matrix->SetElement(i, 1, normalizedY[i]);
>             matrix->SetElement(i, 2, normalizedZ[i]);
>         }
>
>         // Apply the transforms
>         vtkSmartPointer<vtkTransform> transform =
>             vtkSmartPointer<vtkTransform>::New();
>         transform->Translate(startPoint);
>         transform->Concatenate(matrix);
>
>
>
>
>         reslice->SetResliceTransform(transform);
>
>
>         //Step 3: done
>         reslice->Update();
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>