X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 30 Nov 2005 06:23 PM by  anon
Java3D vs IDL plotting 3D spheres
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:3
New Member


--
30 Nov 2005 06:23 PM
    I have just started programming in IDL. Before, I have written a tool in Java (using Java3D) that links an image to a 3D plot, representing feature space. Pixels are visualized as small spheres in the 3D plot and a user can rotate the plot and interactively select these small spheres. I was wondering whether thousands of small spheres can be plotted in a 3D IDL plot and whether this can be done fast and efficiently. My second question relates to interaction and selection in 3D in IDL, ie does IDL allow interactive selections of 3D objects? Thanks and regards, Arko

    Deleted User



    New Member


    Posts:3
    New Member


    --
    30 Nov 2005 06:23 PM
    I have not used Java3D, but visualizing, rotating, scaling and translating plots made up of spherical objects is routine work for IDL Object Graphics, and can be accomplished with a very minimal number of code lines. Here, for example, is a very simple method to display a plot with spherical symbols on a mouse-interactive window: PRO sphere_symbol_plot ; Make some dummy sine curve data x = indgen(20) y = sin(x/3.) z = x ; Define the plot curve symbol to be a blue sphere oSphere = obj_new('orb', COLOR=[0, 0, 255]) oSphere->Scale, .75, .1, .5 ; Scale the default unit sphere to a nice size for XPLOT3D oSymbol = obj_new('IDLgrSymbol', oSphere) xplot3d, x, y, z, THICK=2, SYMBOL=oSymbol END When you mention wanting to do thousands of small spheres, where a sphere represents a pixel, I actually don't picture in my head a "plot" like the one demonstrated above. I envision more an array of free-standing spheres. Here is code that makes a simple gridded array of spheres on an 800x500 window: PRO sphere_image ; Make 1000 random RGB color tripletes sphereColors = byte(randomu(seed, 3, 40, 25) * 256) ; Make the "sphere image" in a 40 x 25 grid sphereImg = objarr(40,25) for i = 0, 24 do begin for j = 0, 39 do begin sphereImg[j,i] = obj_new('orb', POS=[j*20+10,i*20+10,0], $ RADIUS=10.0, COLOR=sphereColors[*,j,i]) endfor endfor oModel = obj_new('IDLgrModel') for i = 0, 999 do oModel->Add, sphereImg[i] ; Don't need [i,j] referencing in IDL ; Add directional light to the model to highlight the 3D shape of the spheres oLight = obj_new('IDLgrLight', LOCATION=[799,499,12], TYPE=2) oModel->Add, oLight oView = obj_new('IDLgrView', LOCATION=[0,0], DIMENSIONS=[800,500], $ VIEWPLANE_RECT=[0,0,800,500], ZCLIP=[10,-10], EYE=12) oWindow = obj_new('IDLgrWindow', DIMENSIONS=[800,500], RETAIN=2) oView->Add, oModel oWindow->Draw, oView obj_destroy, oView ; Clean up END In this case, selecting a given sphere is easy. If the "oWindow" were an IDL draw widget (WIDGET_DRAW), then the event handler that handles the button click could run: selectedObjs = oWindow->Select(oView, [event.x, event.y]) to get ana array of the handles of all the Objects whose images display to the point where the mouse was clicked plus or minus one pixel around that point. And, although the current 'oView' above is not optimal for viewing transformations of this grid, rotating, scaling or translating the above grid is as easy as running commands like "oModel->Rotate" or "oModel->Scale" or "oModel->Translate" followed by a reinvocation of "oWindow->Draw, oView". Hope this helps you compare IDL to Java3D. For the details of IDL Object Programming see the topic 'Programmer's Guides -> Object Programming' in Online Help's Contents tab page. James Jones
    You are not authorized to post a reply.