1vpNormalIndex(3) Library Functions Manual vpNormalIndex(3)
2
3
4
6 vpNormalIndex, vpNormal - encode/decode a surface normal vector
7
9 #include <volpack.h>
10
11 int
12 vpNormalIndex(nx, ny, nz)
13 double nx, ny, nz;
14
15 vpResult
16 vpNormal(n, nx_ptr, ny_ptr, nz_ptr)
17 int n;
18 double *nx_ptr, *ny_ptr, *nz_ptr;
19
21 nx X component of surface normal vector.
22
23 ny Y component of surface normal vector.
24
25 nz Z component of surface normal vector.
26
27 n Encoded surface normal vector.
28
29 nx_ptr Pointer to storage for returning X component of surface normal
30 vector.
31
32 ny_ptr Pointer to storage for returning Y component of surface normal
33 vector.
34
35 nz_ptr Pointer to storage for returning Z component of surface normal
36 vector.
37
39 These two routines are used to convert surface normal vectors between
40 encoded and unencoded forms. An unencoded vector is described by its
41 three components (stored as double-precision floating point numbers) in
42 an orthogonal coordinate system. An encoded vector is described by a
43 single integer that is suitable for use as an index in a shading lookup
44 table. VolPack's built-in shading routines require the use of surface
45 normal vectors encoded using vpNormalIndex (or one of the higher-level
46 normal vector computation routines, vpVolumeNormals or vpScanlineNorā
47 mals). User-defined shading routines or lookup tables are not required
48 to use encoded normal vectors.
49
50 vpNormalIndex computes an encoded vector from the components of an
51 unencoded vector. The vector must be normalized (nx*nx + ny*ny + nz*nz
52 = 1). The maximum possible value of an encoded normal is given by the
53 constant VP_NORM_MAX.
54
55 vpNormal computes the components of a vector from the encoded integer
56 form. The encoded normal has less resolution than the unencoded form,
57 so the vector computed by vpNormal may not be equal to the original
58 vector passed to vpNormalIndex.
59
61 vpNormalIndex always returns a valid encoded normal vector.
62
63 vpNormal normally returns the value VP_OK. The following return value
64 is possible:
65
66 VPERROR_BAD_VALUE
67 The encoded normal vector is invalid.
68
70 VolPack(3), vpVolumeNormals(3), vpScanlineNormals(3)
71
72
73
74VolPack vpNormalIndex(3)