Re: ScreenCoords

Hi Adele,

The only thing I notice is that the inputs to getScreenCoords()
are 3-D graphics coordinates, rather than RealType values. But
you are passing it RealType values from the calls to
Set.getSamples(). RealType values can be converted to 3-D
graphics coordinates (i.e., XAxis, YAxis and ZAxis values)
by calls to the scaleValues() methods of your ScalarMaps
to XAxis, YAxis and ZAxis.

But then the puzzle is why does your code work when you don't
change the plot?

Faced with a problem like yours, I would print out the values
(in their RealType values, their 3-D graphics coordinates, and
their screen coordinates) for a few points and compare those
to rough hand calculations, to try to figure out where it goes
wrong.

Good luck,
Bill
p.s., You have a clever approach.

On Mon, 3 Mar 2003, Adele Cutler wrote:

> Hi Everyone,
>
>       I have a 2-D scatter diagram with a CurveManipulationRenderer that works
> very nicely to select data points inside multiple curves. Now, I'm trying to
> extend it to 3D. What I would like is to be able to rotate and/or zoom the
> plot, with the Curves, and when a button is pressed, I would like to be able
> to select the data points that currently appear inside the Curves.
>
>       So, I get ScreenCoords for the data points(3D) and for the curve
> samples(2D, so I put z=0). It seems to work when I don't change the plot,
> but once I zoom or rotate, it no longer works (I get unpredictable results -
> sometimes more points are selected, sometimes fewer are selected, etc). I've
> looked at the screen coordinates of both the data points and the curves, and
> they all look to be changing predictably as I zoom/rotate the plot, but I'm
> obviously missing something.
>
>       Any suggestions very much appreciated!
>
>       Adele
>
> Here is the bit of code I am using (inside the actionPerformed of my
> button):
>
> //nrows is the number of data points
> //I've checked that dataset[ixvar],dataset[iyvar] and dataset[izvar] are
> correct
>
> DisplayRenderer dr = display.getDisplayRenderer();
> MouseBehavior mb = dr.getMouseBehavior();
> //
> float[] x = new float[nrows];
> float[] y = new float[nrows];
> for(int i=0;i<nrows;i++){
>       //save the screen coordinates of the data point:
>       double[] position = new double[] {      (double)dataset[ixvar][i],
>                                                       
> (double)dataset[iyvar][i],
>                                                       
> (double)dataset[izvar][i]};
>       int[] screen = mb.getScreenCoords(position);
>       x[i] = (float)screen[0];
>       y[i] = (float)screen[1];
> }
> boolean[] selected = new boolean[nrows];
> for(int i=0;i<nrows;i++) selected[i]=false;
> SampledSet[] sets = set.getSets();
> //
> for(int j=1; j<sets.length; j++){//starts from 1 (invisible starter set)
>       float[][] samples = sets[j].getSamples(true); //extract the samples
>       boolean yes = DelaunayCustom.checkAndFixSelfIntersection(samples);
>       //save the screen coordinates of the points on the curve:
>       float[][]samp = new float[2][samples[0].length];
>       for(int
> jj<samples[0].length;jj++){
>               double[] position = new double[] {      (double)samples[0][jj],
>                                                               
> (double)samples[1][jj],
>                                                               (double)0.0};
>               int[] screen = mb.getScreenCoords(position);
>               samp[0][jj] = (float)screen[0];
>               samp[1][jj] = (float)screen[1];
>       }
>       for (int i=0; i<nrows; i++) {
>               // test to see if the screen coordinates for this data point are
>               // inside the screen coordinates of the sampled curve:
>               if(DelaunayCustom.inside(samp,x[i],y[i])) {
>                       selected[i] = true;
>               }
>       }
> }
>
>
>


  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: