Re: Point in Triangle (fwd)

Sorry, the last question was really silly,
I have seen now, that I do have a 2D-Array in were i can find the values
with heightField[j][k]. Is the height value at the same index, as in
interpolateSet? That means for me, the last stored value?

Thanks for your help Desiree



o------------------------------------------------------------------------o
| Desiree Hilbring      Institut fuer Photogrammetrie und Fernerkundung  | 
|                       Universitaet Karlsruhe, Germany                  |
|                                                                        |
|                       email: hilbring@xxxxxxxxxxxxxxxxxxxx             |
|                       # 0721 6083676                                   |
o------------------------------------------------------------------------o

---------- Forwarded message ----------
Date: Fri, 23 Feb 2001 15:00:35 +0100 (MET)
From: Desiree Hilbring <hilbring@xxxxxxxxxxxxxxxxxxxx>
To: Curtis Rueden <curtis@xxxxxxxxxxxxx>
Subject: Re: Point in Triangle


Hi All of You,

I tried to get the interpolated point height with the resample method.
I am not sure, if the follwowing is right:

RealTupleType xy = new RealTupleType(x, y);
            FunctionType terrain_type = new FunctionType(xy, height);
            Irregular2DSet set = new Irregular2DSet(xy,new float[][]
{eastValues,northValues});
            FlatField terrain = new FlatField(terrain_type, set);
            terrain.setSamples(new float[][] {heightValues});

            // data for new set
            // all old point + 1 given new point, from which I want
            // to know the height
            float[] eastValuesIntpol = new float[eastValues.length+1];
            float[] northValuesIntpol = new float[northValues.length+1];
            for (int i=0;i<northValues.length;i++) {
                eastValuesIntpol[i]=eastValues[i];
                northValuesIntpol[i]=northValues[i];
                System.out.println("eastValue"+eastValues[i]);
                System.out.println("northValue"+northValues[i]);
            }
            // this is the new point
            eastValuesIntpol[eastValuesIntpol.length-1]=conEast;
            northValuesIntpol[northValuesIntpol.length-1]=conNorth;
            // this is the new set
            Irregular2DSet interpolateSet = new Irregular2DSet(xy, new
float[][] {eastValuesIntpol,northValuesIntpol});
            // here I am using the resample method
            Field heightField
terrain.resample(interpolateSet,Data.WEIGHTED_AVERAGE,Data.NO_ERRORS);

            System.out.println("HeightFiels Laenge
"+heightField.getLength());
            double[][] wert = heightField.getValues();
            System.out.println(wert.length);
            for (int j=0;j<wert.length;j++) {
                System.out.println("wert "+wert[j][j]);
            }

Why do I get only on vlaue in the double[][] wert Array?
Should this be the interpolated height?
I checked this and chose for the unknown point one of the given points,
but the calculated value is different from the original height value of
the point.

What is resample doing?

Thanks for your help in advance

Desiree

o------------------------------------------------------------------------o
| Desiree Hilbring      Institut fuer Photogrammetrie und Fernerkundung  | 
|                       Universitaet Karlsruhe, Germany                  |
|                                                                        |
|                       email: hilbring@xxxxxxxxxxxxxxxxxxxx             |
|                       # 0721 6083676                                   |
o------------------------------------------------------------------------o

On Thu, 22 Feb 2001, Curtis Rueden wrote:

> Hi Desiree,
> 
> The method valueToTri of Irregular2DSet does what you want.  Given
> an array of samples, valueToTri returns an array of indices into the
> Irregular2DSet's triangles.  Unfortunately, valueToTri is marked
> private right now.  I will change the method to public for the next
> VisAD release, but in the meantime, you should be able to change it
> yourself and recompile without any ill effects.
> 
> After marking valueToTri as public, something like the following
> should work for you to find the containing triangle for a sample
> (or list of triangles for multiple samples):
> 
> //---------------
> 
> // construct Irregular2DSet
> float[][] samples = new float[][] {eastValues, northValues});
> Irregular2DSet set = new Irregular2DSet(xy, samples);
> 
> // allocate array for sample for which containing triangle is desired
> float[][] samp = new float[2][1];
> samp[0][0] = x_coord; // x coordinate of sample
> samp[1][0] = y_coord; // y coordinate of sample
> 
> // determine containing triangle
> int[] indices = set.valueToTri(samp);
> int[] tri = set.Delan.Tri[indices[0]];
> 
> // output values of triangle vertices
> for (int i=0; i<tri.length; i++) {
>   System.out.println("Triangle " + (i + 1) + ":");
>   for (int j=0; j<2; j++) System.out.print(" " + samples[j][tri[i]]);
>   System.out.println();
> }
> 
> //---------------
> 
> -Curtis
> 
> At 09:16 2/22/01, you wrote:
> >Hi,
> >
> >I have a given set of 3D-point and the x,y-coordinates of one point
> >somewhere in my set of points. I
> >want to interpolate the height of the point. 
> >I want to add this point in my set and use the Delaunay-Triangulation of
> >VisAD. 
> >Without this extra point the Delaunay Triangulation is working fine.
> >
> >RealType x = RealType.getRealType("x");
> >        RealType y = RealType.getRealType("y");
> >        RealType height = RealType.getRealType("height");
> >        try {
> >            RealTupleType xy = new RealTupleType(x, y);
> >            FunctionType terrain_type = new FunctionType(xy, height);
> >            Irregular2DSet set = new Irregular2DSet(xy,new float[][]
> >{eastValues,northValues});
> >            FlatField terrain = new FlatField(terrain_type, set);
> >            terrain.setSamples(new float[][] {heightValues});
> >                    
> >            display = new DisplayImplJ3D("display1");
> >            ScalarMap hoxmap = new ScalarMap(x, Display.XAxis);
> >            ScalarMap reymap = new ScalarMap(y, Display.YAxis);
> >            ScalarMap heightmap = new ScalarMap(height, Display.ZAxis);
> >                    
> >            display.addMap(hoxmap);
> >            display.addMap(reymap);
> >            display.addMap(heightmap);
> >                
> >            hoxmap.setRange(-1.0, 1.0);
> >            reymap.setRange(-1.0, 1.0);
> >            heightmap.setRange(-1.0, 1.0);
> >            
> >            DataReferenceImpl data_ref = new
> >DataReferenceImpl("data_ref"); 
> >            data_ref.setData( terrain );
> >            renderer = new DefaultRendererJ3D();
> >            display.addReferences(renderer,data_ref);
> >            display.addDisplayListener(listener);
> >        }
> >        catch (VisADException ve) {
> >            System.out.println("VisAd TupleType Exception");
> >        }       
> >        catch (RemoteException re) {
> >            System.out.println("RemoteExcpetion");
> >        }
> >
> >How can I find the triangle in which the point belongs to?
> >Are there some standard geometric algorithms to achieve that?
> >Where do I have to look at.
> >
> >Thanks for your help in advance
> >
> >Desiree
> >
> >
> >
> >o------------------------------------------------------------------------o
> >| Desiree Hilbring      Institut fuer Photogrammetrie und Fernerkundung  | 
> >|                       Universitaet Karlsruhe, Germany                  |
> >|                                                                        |
> >|                       email: hilbring@xxxxxxxxxxxxxxxxxxxx            |
> >|                       # 0721 6083676                                  |
> >o------------------------------------------------------------------------o
> 
> 



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