Re: generating quadric surfaces

Hi John,

> I have been generating data to form quadric surfaces (i.e. ellipsoid,
> hyperboloid of one and two sheets) with the following code:
> 
> for(int i=0;i<resol+1;i++)
>          {
>              thelta = thelta_gap*i+start;
> 
>              for(int j=0;j<resol+1;j++)
>              {
>                  phi = phi_gap*j;
> 
>                  dx = Math.sin(thelta)*Math.cos(phi);
>                  dy = Math.cos(thelta);
>                  dz = Math.sin(thelta)*Math.sin(phi);
> 
>                  Sn = dx*dx*stress[1]+dy*dy*stress[0]+
>                  
> dz*dz*stress[2]+2.*(dx*dy*stress[3]+dy*dz*stress[4]+dx*dz*stress[5]);
> 
>                  if(Sn<=0.) tempVal = 0.;
>                  else tempVal = Math.sqrt(k*k/Math.abs(Sn));
>                  xCoord[counter] = (float)(tempVal*dx);
>                  yCoord[counter] = (float)(tempVal*dy);
>                  zCoord[counter] = (float)(tempVal*dz);
> 
>              }
>                  xCoord[counter] = xCoord[counter-resol];
>                  yCoord[counter] = yCoord[counter-resol];
>                  zCoord[counter] = zCoord[counter-resol];
>                  counter++;
>          }

There is something funny about this code: each iteration of the
inner loop over-writes the values the previous iteration wrote
into the xCoord, yCoord and zCoord arrays.

> But problems occur when the shape is either hyperboloid of one sheet or two
> sheet.  For hyperboloid of two sheet, the parts of the two sheets that are
> close to the origin becomes white (fading away).  For hyperboloid of one
> sheet only portions that are close to the origin are
> recognizable.  Geometry "fades" and becomes spiky when moving away from the
> origin.
> 
> Does anyone have some ideas on how I can fix this problem?  Thanks very much.

If your application doesn't disable texture mapping (via
the GraphicsModeControl) then your surface will be under
sampled. But that shouldn't change as you move the view
point. That behavior sounds like a Java3D problem.

However, try disabling texture mapping:

  display.getGraphicsModeControl().setTextureEnable(false);

It may help.

Good luck,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html


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