# reslice using an arbitrary orientation Classic List Threaded 2 messages Reply | Threaded
Open this post in threaded view
|

## reslice using an arbitrary orientation

 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? Thanks in advance   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 matrix =             vtkSmartPointer::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 transform =             vtkSmartPointer::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_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.htmlPlease keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQSearch the list archives at: http://markmail.org/search/?q=vtkusersFollow this link to subscribe/unsubscribe: https://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

## Re: reslice using an arbitrary orientation

 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? thanksEl lun., 25 mar. 2019 a las 20:08, zandarina (<[hidden email]>) 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? Thanks in advance   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 matrix =             vtkSmartPointer::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 transform =             vtkSmartPointer::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 _______________________________________________ Powered by www.kitware.com 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 Follow this link to subscribe/unsubscribe: https://vtk.org/mailman/listinfo/vtkusers _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.htmlPlease keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQSearch the list archives at: http://markmail.org/search/?q=vtkusersFollow this link to subscribe/unsubscribe: https://vtk.org/mailman/listinfo/vtkusers