This file contains the rendering code for Illuminator, which renders 2-D or 3-D data into an RGB(A) unsigned char array (using perspective in 3-D).
#define __FUNCT__ "pseudocolor"
#define __FUNCT__ "pseudoternarycolor"
#define __FUNCT__ "pseudohueintcolor"
#define __FUNCT__ "pseudoshearcolor"
#define __FUNCT__ "render_scale_2d"
#define __FUNCT__ "render_rgb_local_2d"
#define __FUNCT__ "render_rgb_local_3d"
The coordinate transformation is pretty simple. A point p in space is transformed to x, y on the screen by representing it as:
This system can easily be solved for x and y by first making it into a matrix equation:
a | = | M00 (px-ix) + M01 (py-iy) + M02 (pz-iz), |
x | = | [M10 (px-ix) + M11 (py-iy) + M12 (pz-iz)] / a, |
y | = | [M00 (px-ix) + M01 (py-iy) + M02 (pz-iz)] / a. |
The triple product of the vector from the light source to the triangle centroid and the two vectors making up the triangle edges determines the cosine of the angle made by the triangle normal and the incident light, whose absolute value is used here to shade the triangle. At this point, the light source is taken as the observer location at "eye", but that can easily be modified to use one or more independent light sources.
static inline void pseudocolor ( PetscScalar val, PetscScalar* scale, guchar* pixel )