# IBM Visualization Data Explorer Programmer's Reference

## 13.9 Basic Data Types

This section describes some basic data types used by the system, including points, vectors, triangles, colors, and matrices.

### Points and Vectors

Points are represented by the Point structure. Data Explorer provides a routine that constructs a point structure. Vectors are represented by the same structure as points, but for the sake of clarity they are defined as a separate type.
```typedef struct point {
float x, y, z;
} Point, Vector;
typedef int PointId;
```
 Point DXPt() Point DXVec(); Construct a Point or a Vector with the given coordinates. See DXPt, DXVec.

### Lines, Triangles, Quadrilaterals, Tetrahedra, and Cubes

These data structures define the interpolation elements of an Object. They refer to points by point identifiers.

```
typedef struct line {
PointId p, q;
} Line;
typedef struct triangle {
PointId p, q, r;
} Triangle;
PointId p, q, r, s;
typedef struct tetrahedron {
PointId p, q, r, s;
} Tetrahedron;
typedef struct cube {
PointId p, q, r, s, t, u, v, w;
} Cube;

```
Figure 9 shows the order of vertices in each structure. For more information about connections and the order of vertices, see Chapter 3. "Understanding the Data Model" in IBM Visualization Data Explorer User's Guide.

Figure 9. Order of Vertices in Connection Elements. In the tetrahedron at right, s is the point nearest the viewer; in the tetrahedron at center, the point furthest from the viewer.
 Line DXLn() Triangle DXTri(); Quadrilateral DXQuad(); Tetrahedron DXTetra(); Construct a line, triangle, quadrilateral, and tetrahedron respectively, given the appropriate point identifiers. See DXLn, DXTri, DXQuad, DXTetra.

### Colors

Colors define the photometric characteristics of an Object; they may be associated with points, triangles, or lights, and may be used to define its reflectance or opacity. In Data Explorer, colors are floating-point numbers and therefore open ended, as is light intensity in the real world. However, real output devices can display only a limited range of intensities. In general, the range from 0.0 to 1.0 is by default mapped onto the range of displayable intensities of the output device, so colors should normally be specified in this range. Data Explorer provides a routine that constructs an RGB color structure.

```typedef struct rgbcolor {
float r, g, b;
} RGBColor;
```
 RGBColor DXRGB() Constructs an RGB color structure with the given components. See DXRGB. Error DXColorNameToRGB() Gets the RGB values for a specified colorname string. See DXColorNameToRGB.

### Angles

Angles are expressed as floating-point numbers in radians. The following macros express angles in units that might be more convenient. For example, 5*DEG is 5 degrees in radians.

```typedef double Angle;
#define DEG (6.283185307179586476925287/360)
```

### Transformation Matrices

Transformation matrices (or transforms) specify the relationship between Objects. For example, when a renderable object is included in a model, a transformation matrix specifies its placement. In Data Explorer, a transform is a 4×3 matrix specifying rotation and translation. This is a homogeneous matrix without the part that computes the w component of the result. (The w component is used for perspective, which is specified by a camera and is not needed here.)

```typedef struct matrix {
/* xA + b */
float A[3][3];
float b[3];
} Matrix;
static Matrix mdentity = {
1, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0
};
```

Transforms can be specified in a number of ways:
 Matrix DXRotateX() Matrix DXRotateY(); Matrix DXRotateZ(); Return a Matrix that specifies a rotation (in radians) about the x, y or z axis by angle angle. See DXRotateX, DXRotateY, DXRotateZ, DXScale, DXTranslate, DXMat. Matrix DXScale() Returns a Matrix that specifies a scaling by amounts x, y, and z along the x, y and z axes. See DXRotateX, DXRotateY, DXRotateZ, DXScale, DXTranslate, DXMat. Matrix DXTranslate() Returns a Matrix that specifies a translation by vector v. See DXRotateX, DXRotateY, DXRotateZ, DXScale, DXTranslate, DXMat. Matrix DXMat() Returns a Matrix with the specified components. See DXRotateX, DXRotateY, DXRotateZ, DXScale, DXTranslate, DXMat.

### Basic Operations

A number of basic operations on the Matrix, Point, and Vector types are defined here. Operations declared as operating on type Vector also work on Point because both are type-defined for structure. These operations all take their arguments by value and return the result.