I have three 3D points with an known Z value:
point 1 = (0, 0, Z1)
point 2 = (64, 0, Z2)
point 3 = (64, 64, Z3)
I need an equation to solve for the Z value given an X and Y position within these 3 points. assuming a flat gradient between these points.
thanks in advanced:
I assume here you mean that you want a function $z(x,y)$ which tells you the coordinates of a point on the plane given its first two coordinates. This can be done.
For convenience, change coordinates such that one of your points is the origin. For your case we'll do so with the first point, changing to $z'=z-z_1$. Once you have done that, your plane is defined by
$$ax+by+cz'=0$$
You can find the normal by plugging in your points; you get a system
$$\begin{bmatrix} x_1 & x_2 & x_3 \\ y_1 & y_2 & y_3 \\ z'_1 & z'_2 & z'_3 \end{bmatrix} \begin{bmatrix} a \\ b \\ c \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}.$$
This system will have a nontrivial solution because one of the columns will be all zero, by construction. In higher dimensions you can solve this system by row reduction or similar. In 3 dimensions you can use the cross product of the two nonzero vectors.
Let's work this out for your case. The vectors are
$$(x,y,z')=(0,0,0),(64,0,z_2-z_1),(64,64,z_3-z_1).$$
So the normal is the cross product of $(64,0,z_2-z_1)$ and $(64,64,z_3-z_1)$. This is given by
$$(x,y,z')=(-64(z_2-z_1),64(z_2-z_1)-64(z_3-z_1),4096)=(-64(z_2-z_1),64(z_2-z_3),4096).$$
Changing coordinates back, we have
$$-64(z_2-z_1)x+64(z_2-z_3)y+4096(z-z_1)=0.$$
Rearrange to get
$$z(x,y)=z_1+\frac{64(z_2-z_1)}{4096}x+\frac{64(z_3-z_2)}{4096}y.$$