```
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glut.h>
#include<stdlib.h>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <fstream>
#include<math.h>
#include<windows.h>
#include<conio.h>
using namespace std;
double VectorLength(float x,float y,float z)
{
return sqrt((x*x) + (y*y)+ (z*z));
}
double Normalize(float x,float y,float z)
{
double len =VectorLength(x,y,z);
x /= len;
y /= len;
z /= len;
double vc[3] = {x,y,z};
return vc[3];
}
double vectorSub(float*p1,float*p2)
{
float U[3];
U[0] = p2[0]-p1[0];
U[1] = p2[1]-p1[1];
U[2] = p2[2]-p1[2];
return U[3];
}
double crossProduct(float*u,float*v)
{
float uv[3];
float Normalizeduv[3];
uv[0]=u[1]*v[2]-u[2]*v[1];
uv[1]=u[2]*v[0]-u[0]*v[2];
uv[2]=u[0]*v[1]-u[1]*v[0];
Normalizeduv[3] = Normalize(uv[0],uv[1],uv[2]);
return Normalizeduv[3];
}
double computeSurfaceNormal(float*p1,float*p2,float*p3)
{
float u[3];
float v[3];
u[3]= vectorSub(p1,p2);
v[3]= vectorSub(p1,p3);
float SurfaceNormal[3];
SurfaceNormal[3]= crossProduct(u,v);
return SurfaceNormal[3];
}
int main()
{
float p1[3]={1,1,0};
float p2[3]={1,1,1};
float p3[3]={1,0,0};
float SurfaceNormal1[3];
SurfaceNormal1[3]= static_cast<int> (computeSurfaceNormal(p1,p2,p3));
for (int i=0; i<3; i++)
{
cout << "Value for myArray[" << i << "]: ";
cout <<SurfaceNormal1[i]<<"\n";
}
getch();
}
```