This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: "Stuart Wier" <address@hidden> >Organization: UNAVCO >Keywords: 200408101823.i7AIN75R027284 VisAD shapes Hi Stu- >Institution: UNAVCO >Package Version: 1.1b3 >Operating System: linux >Hardware Information: intel >Inquiry: In IDV class ShapeUtility (see code below) for defining a cube shape > you say the values of "coordinates" are "xyz coordinates of the vertices." A > cube has 8 vertices, but the array has 144 numbers in it. Even if the vertic > es apply more than once, ie 4 vertices on each of 6 sides, there are only 24 > vertices and 72 xyz values. What is the defining rule here? Does vertex ord > er matter? Likewise I can't figure out the normals; there are a lot of them a > nd what is the association with faces or vertices? Every two consecutive (x,y,z) pairs defines one side of one face of the cube. That give 2(points)x4(sides)x3(values (xyz)/point) = 24 values for each face and for 6 faces, that makes 144 numbers. This could probably be done with fewer points - I forget where the code came from. You could play around to see if it works with one xyz point per vertex. > > >else if (s.equals(CUBE)) { > shape = new VisADQuadArray(); > shape.coordinates = new float[] { > 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, > -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, > -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, > -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, > -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, > 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, > 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, > 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, > -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, > 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, > -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, > -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, > 1.0f, -1.0f, 1.0f > }; The normals are perpendicular to each face. So, for the first 24 values the normal is the -1 Z axis, etc. > shape.normals = new float[144]; > for (int i = 0; i < 24; i += 3) { > shape.normals[i] = 0.0f; > shape.normals[i + 1] = 0.0f; > shape.normals[i + 2] = -1.0f; > > shape.normals[i + 24] = 0.0f; > shape.normals[i + 25] = 0.0f; > shape.normals[i + 26] = 1.0f; > > shape.normals[i + 48] = 1.0f; > shape.normals[i + 49] = 0.0f; > shape.normals[i + 50] = 0.0f; > > shape.normals[i + 72] = -1.0f; > shape.normals[i + 73] = 0.0f; > shape.normals[i + 74] = 0.0f; > > shape.normals[i + 96] = 0.0f; > shape.normals[i + 97] = 1.0f; > shape.normals[i + 98] = 0.0f; Hope that helps. Like I said, I just drew a picture and plotted the first few points to figure out what was what. I don't claim to be an expert on 3D geometry. ;-) Don Murray NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publically available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.