[Paraview] how to change the position and orientation of arrows in paraview?

骆沛 areslp at gmail.com
Wed May 30 02:14:43 EDT 2012


I got something like this, but it didn't work...It's a python script.
Each line in "D.txt" is a vector b, and I want to transform the default
arrow(vector a) to b's direction.
Firstly I calculate Quaternions to represent the rotation, then I got the
euler angle from the quaternions.
What's wrong with the following code? Please help me! Thanks a lot!!

try: paraview.simple
> except: from paraview.simple import *
> paraview.simple._DisableFirstRenderCameraReset()
> from math import *
> from numpy import *
> from numpy.linalg import *
>
>
> f=open('D.txt')
> for line in iter(f):
>     # print line
>     items=line.split()
>     arrow=Arrow()
>     arrow = GetActiveSource()
>     arrow.TipRadius = 0.05
>     arrow.TipResolution = 32
>     arrow.ShaftRadius = 0.01
>     arrow.TipLength = 0.2
>     arrow.ShaftResolution = 32
>     dr=GetDisplayProperties(arrow)
>     dr.DiffuseColor = [1.0, 0.0, 0.0]
>     dr.Origin = [0.0, 0.0, 0.0]
>     dr.Position = [2.69616, 15.2011, -2.68065]  # tried with [0,0,0], same
> result
>     dr.Scale = [0.02, 0.02, 0.02]
>     e=array([1, 0, 0])   #vector a
>     print 'e:',e
>     u=array([float(items[0]),float(items[1]),float(items[2])])   #vector b
>     print 'u:',u
>
>
>     v=cross(u,e) #rotation axis
>     print 'v:',v
>     print 'norm(v):',norm(v)
>     v=v/norm(v)
>
>     #Quaternions
>     print 'u*e:',dot(u,e)
>     a=acos(dot(u,e))
>     q=array([cos(a/2),sin(a/2)*v[0],sin(a/2)*v[1],sin(a/2)*v[2]])
>     print 'q:',q
>     q=q/norm(q)
>     print 'normalized q:',q
>     w=q[0]
>     x=q[1]
>     y=q[2]
>     z=q[3]
>
        ax=atan2(2*(w*x+y*z),1-2*(x**2+y**2))  #ax,ay,az are euler angles

>     ay=arcsin(2*(w*y-z*x))
>     az=atan2(2*(w*z+x*y),1-2*(y**2+z**2))
>     print 'ax:',ax,'ay:',ay,'az:',az
>     dr.Orientation = [180*ax/pi,180*ay/pi,180*az/pi]  #convert to degree
> f.close()
>
> Render()



On Mon, May 28, 2012 at 12:16 PM, 骆沛 <areslp at gmail.com> wrote:

> I add an arrow in Sources, but I don't find the place to set the position
> and orientation of the arrow... Could anyone tell me how can I do this? I
> use paraview3.14 version.
>
> --
> Best Regards
> Areslp
>
>


-- 
Best Regards
Areslp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120530/1c8be8d4/attachment.htm>


More information about the ParaView mailing list