Draw 3d vectors

Hi everybody,

I would like to draw 3d vectors with a good resolution as show in http://root.cern.ch/root/roottalk/roottalk03/1425.html. They will rappresent the dipolar momentum of singular molecules in the space.
So I would like to know your opinion to do that with Root.
a) How is the best way to do it, by using root glviewer or coin3d?
b) It’s possible to open only the glviewer without the TCanvas in the back?
Thank you very much for your help!


To give you the best advice I’d need to know:
a) how many arrows do you expect to have on the screen?
b) would you like to animate things?
c) how important is this for you - do you want to make it right and beautiful or just passable, fast and as painless as possible?
d) when do you need it done - is it a long term project?

In ROOT there is a relatively new module called EVE
for doing interactive visualization with OpenGL. There you don’t need to use the canvas … but you communicate with a TEveManager to register your objects. I’ve attached a trivial script that draws an arrow, similar to the macro that you’ve linked.
See also other demos in $ROOTSYS/tutorials/eve.

If you want to do this right, I can add a new visualization class, TEveArrow, that will make your life easier.

Let me know …
yy.C (539 Bytes)

Hi Matevz,

Thank you for your help and disposition! The example is beautiful!
So I will answer your points:
a) The number of vector will depends of the user input, it can be from 0 to more than 10000 (for example a big protein, etc…).
b) In a first moment no. I will simple show the vectors in the space with the X,Y,Z versors and the origin (my dream in a future is to create and move the vectors in the glviewer and get their position and orientation in a file, but it’s not the first objective, I think that is very Difficult :wink:.
c) I would like only to have a “good” arrow, “the most graphical perfect cone and tube”.
d) It’s a long project, I have just before november/december 2008.

I would like to pass the 3 position’s coordinates of the central point of the tube (= vector position in the space), and 3 coordinates for the orientation (=X,Y,Z), plus a phi angle (= rotation in the arrow axe (it’s not necessary to show it)).

TEve is perfect but I would like to remove the edit bar in the left and the root prompt and add the X,Y,Z axis + origin. I would like to do something like the attachment (a TCanvas with all elements, it is a copy and paste) the 4 elements in the right were completed, but now my problem is the Vectors.
So if it’s possible to you to help me in this “problem” I will thank you very very much!!!

Hi Luis,

OK … I’ll add the TEveArrow class before the end of this week. You’ll have to work with the svn trunk.

If you prefer not to show the eve window, you can do
which will prevent eve from mapping the window.

Then … to get you dream layout, you can go several ways:
a) Create a TGMainFrame and put into it (in horizontal layout) TGLEmbeddedViewer and TRootCanvas
b) Subclass TRootCanvas and try to sneak in TGLEmbeddedViewer
Have a look at the code … I’m not sure which would be best. We’ll help you if you get stuck.

I will provide you a method to register an external GL-viewer (the one that you’ll create in your window) to eve so all redraws/updates will be processed correctly.


Hi Matevz,

Thank you very much for your help, I will try to do that you explained.

We were in private correspondence with Louis … just to recapitulate:

  1. There is a new class TEveArrow, see tutorials/eve/arrow.C
  2. For Louis’ dream layout, see tutorials/eve/arrow_standalone.C