<div>Hi,</div>
<div> </div>
<div>I'm not that familiar with magnetic fields stuff so I've re-worded the problem as follows (to the best that I could understand) and I've also presented a solution:</div>
<div> </div>
<div>Let say we have the coordinates of a few points and we also have vectors (direction and magnitude) that emanate from each point. How do we visualize them?</div>
<div> </div>
<div>There are different ways of doing this. One would be using Glyph3D and ArrowSource in vtk but there is a trick to getting the magnitude of each arrow to be the magnitude of the each force vector. So I have not presented this approach. You can have a look at vtk documentation and examples to see how this works. The other way is to present the vectors as line segments whose length is equal to the force magnitude.
</div>
<div>Here is how this is done:</div>
<div> </div>
<div>1) We create a poly data</div>
<div>2) Loop over the points and:</div>
<div> 2.1) add it to the poly data (this will the starting point of a line segment)</div>
<div> 2.2) compute the end point of the line segment (start point + force) and add it to the poly data</div>
<div> 2.3) add the line segment to the poly data that joins these two points</div>
<div> </div>
<div>Here is a partial C++ code:</div>
<div> </div>
<div>
<p><font face="courier new,monospace">int i; // used in a for-loop<br>int numPoints; // the number of points<br>double x[], y[], z[]; // x,y,z coordinate of the points<br>double vx[], vy[], vz[]; // the x,y,z coordinate of each vector
</font></p>
<p><font face="courier new,monospace">vtkPolyData *vecField = vtkPolyData::New();<br>vtkPoints *pnts = vtkPoints::New();</font></p>
<p><font face="courier new,monospace">vecField->SetPoints( pnts );<br>vecField->Allocate();<br>int numAddedPoints = 0;<br>for(i=0; i<numPoints; i++)<br>{<br> double start[] = { x[i], y[i], z[i] };<br> double end[] = { x[i]+vx[i], y[i]+vy[i], z[i]+vz[i] };
<br> pnts->InsertNextPoint ( start );<br> pnts->InsertNextPoint ( end );</font></p>
<p><font face="courier new,monospace"> int ids[] = { numAddedPoints, numAddedPoints+1 };<br> vecField->InsertNextCell( VTK_LINE, 2, ids );</font></p>
<p><font face="courier new,monospace"> numAddedPoints += 2;<br>}<br>vecField->Squeeze();</font></p>All you need to do now is to use an actor to add the poly data to your scene and render it :)</div><br><br>
<div><span class="gmail_quote">On 8/17/07, <b class="gmail_sendername">yadin Bocuma Rivas</b> <<a href="mailto:conra2004@yahoo.com">conra2004@yahoo.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">hi!<br>i am planning to plot electromagnetic fiels using vtk<br>at the mooment i got the x,y,z coordinates into arrays and i have the magnitude
<br>or intensity of the fields ; that is at every point(x,y,z) i have the value of the corresponding component of the magnetic field in the x,y,z direction ; <br>how can i visualise this magnetidc field with vtk ; which commands can i use?
<br>i matlab I used quiver3(x,y,z,Ex,Ey,Ez) how can i do this with VTK <br><br>is an array of points(x,y,z) and the field is (Ex,Ey,Ez) please how can i start doing these<br><br>thanks <br><span class="ad">
<p>__________________________________________________<br>Correo Yahoo!<br>Espacio para todos tus mensajes, antivirus y antispam ¡gratis! <br>Regístrate ya - <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://correo.espanol.yahoo.com/" target="_blank">
http://correo.espanol.yahoo.com/</a> </p></span><br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers
</a><br><br></blockquote></div><br>