<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">OK, now I see:   transform->Translate(pos)  after the SetMatrix(), and instead of actor->SetPosition().<br>
<br>
    pos[0] = -3; pos[1] = 0; pos[2] = 0;<br>
    transform->SetMatrix(vtkM);<br>
    transform->Translate(pos);<br>
    actor->SetUserTransform(transform);<br>
    pos2[0] = 3; pos2[1] = 0; pos2[2] = 0;<br>
    transform2->SetMatrix(vtkM);<br>
    transform2->Translate(pos2);<br>
    actor2->SetUserTransform(transform2);<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF187333"><font color="#000000" face="Tahoma" size="2"><b>From:</b> vtkusers [vtkusers-bounces@vtk.org] on behalf of Gib Bogle [g.bogle@auckland.ac.nz]<br>
<b>Sent:</b> Friday, 7 November 2014 9:32 a.m.<br>
<b>To:</b> David Gobbi<br>
<b>Cc:</b> vtkusers@vtk.org<br>
<b>Subject:</b> Re: [vtkusers] Transform axes<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hi David,<br>
<br>
I obviously have not fully grasped the concept, although I've looked at a few examples and the vtkTransform docs.<br>
<br>
In my test code I want to place two actors, each with its own orientation.  In the code below they are given the same orientation - the transform is intended to take the local (x,y,z) axes to global (y,z,x), and in fact the rotation I get is correct.  But I
 am unable to place the actors where I want.  They finish up at (0,-3,0) and (0,3,0), in other words pos[] and pos2[2] are in the rotated coordinate system.  How do I rotate the actors and set their positions in the (unchanged) global coordinates?<br>
<br>
    vx[0] = 0;<br>
    vx[1] = 1;<br>
    vx[2] = 0;<br>
    vy[0] = 0;<br>
    vy[1] = 0;<br>
    vy[2] = 1;<br>
    vz[0] = 1;<br>
    vz[1] = 0;<br>
    vz[2] = 0;<br>
    double M[4][4] = {{vx[0],vy[0],vz[0],0}, {vx[1],vy[1],vz[1],0}, {vx[2],vy[2],vz[2],0}, {0,0,0,1}};<br>
    for (int i=0; i<4; i++) {<br>
        for (int j=0; j<4; j++) {<br>
            vtkM->SetElement(i,j,M[i][j]);<br>
        }<br>
    }<br>
<br>
    pos[0] = -3; pos[1] = 0; pos[2] = 0;<br>
    transform->SetMatrix(vtkM);<br>
    actor->SetUserTransform(transform);<br>
    actor->SetOrigin(0,0,0);<br>
    actor->SetPosition(pos);<br>
<br>
    pos2[0] = 3; pos2[1] = 0; pos2[2] = 0;<br>
    transform2->SetMatrix(vtkM);<br>
    actor2->SetUserTransform(transform2);<br>
    actor2->SetOrigin(0,0,0);<br>
    actor2->SetPosition(pos2);<br>
<br>
Thanks<br>
Gib<br>
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<hr tabindex="-1">
<div id="divRpF677400" style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>From:</b> David Gobbi [david.gobbi@gmail.com]<br>
<b>Sent:</b> Thursday, 6 November 2014 5:34 p.m.<br>
<b>To:</b> Gib Bogle<br>
<b>Cc:</b> vtkusers@vtk.org<br>
<b>Subject:</b> Re: [vtkusers] Transform axes<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">Hi Gib,
<div><br>
</div>
<div>If I'm reading your question correctly, then what you are looking</div>
<div>for is very easy to achieve.</div>
<div><br>
</div>
<div>To transform an object from its canonical x,y,z axes onto a</div>
<div>new set of orthogonal axes, all you need is to set the first three</div>
<div>columns of a 4x4 matrix to those axes.</div>
<div><br>
</div>
<div>if the axis vectors are u, v, and w, then the transform matrix is</div>
<div><br>
</div>
<div>u_x, v_x, w_x, 0,</div>
<div>u_y, v_y, w_y, 0,</div>
<div>u_z, v_z, w_z, 0,</div>
<div>0, 0, 0, 1</div>
<div><br>
</div>
<div>No algebra involved!</div>
<div><br>
</div>
<div> - David</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Nov 5, 2014 at 5:47 PM, Gib Bogle <span dir="ltr">
<<a href="mailto:g.bogle@auckland.ac.nz" target="_blank">g.bogle@auckland.ac.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hi all,<br>
<br>
This is a 3D geometry problem, one that many people must have solved.  I want to apply a transform to my actor to bring it's local axes (which are initially aligned with the global axes) into alignment with a specified triplet of orthogonal vectors.  In fact
 alignment with a pair is sufficient.  I'm hoping that somebody has done this in VTK and can save me the trouble of going through the algebra.<br>
<br>
Thanks<span class="HOEnZb"><font color="#888888"><br>
Gib<br>
</font></span></div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>