# Implement a function

In this question you need to implement a function for computing the achromatic Phong illumination at a surface point.

The function declaration is:

void phongIlluminationAchromatic(double* reflectedLightPtr,

double ambientIntensity, double diffuseIntensity, double specularIntensity,

double ambientReflecCoef, double diffuseReflecCoef, double specularReflecCoef,

double shininess,

double kc, double kl, double kq,

Vec3d pointOnSurface, Vec3d surfaceNormal, Vec3d lightPosition, Vec3d viewPoint)

The value of the variable reflectedLight should be the Phong illumination calculated with the achromatic Phong Illumination model presented in the lecture.

ambientIntensity, diffuseIntensity, and specularIntensity are the intensities of the incoming light hitting the surface.

ambientReflecCoef, diffuseReflecCoef, and specularReflecCoef are the reflection coefficients of the surface.

shininess is the exponent alpha in the specular reflection component of the Phong Illumination formula.

kc, kl and kq are constants used for computing how the distance between light source and surface point effects the reflected light intensity.

pointOnSurface is the point on the surface for which you should compute the reflected light intensity.

surfaceNormal is the surface normal at that point.

lightPosition and viewPoint are the locations of the light and of the viewer (camera) in the scene.

Note that all of these vectors are not normalised.

The function declaration is:

void phongIlluminationAchromatic(double* reflectedLightPtr,

double ambientIntensity, double diffuseIntensity, double specularIntensity,

double ambientReflecCoef, double diffuseReflecCoef, double specularReflecCoef,

double shininess,

double kc, double kl, double kq,

Vec3d pointOnSurface, Vec3d surfaceNormal, Vec3d lightPosition, Vec3d viewPoint)

The value of the variable reflectedLight should be the Phong illumination calculated with the achromatic Phong Illumination model presented in the lecture.

ambientIntensity, diffuseIntensity, and specularIntensity are the intensities of the incoming light hitting the surface.

ambientReflecCoef, diffuseReflecCoef, and specularReflecCoef are the reflection coefficients of the surface.

shininess is the exponent alpha in the specular reflection component of the Phong Illumination formula.

kc, kl and kq are constants used for computing how the distance between light source and surface point effects the reflected light intensity.

pointOnSurface is the point on the surface for which you should compute the reflected light intensity.

surfaceNormal is the surface normal at that point.

lightPosition and viewPoint are the locations of the light and of the viewer (camera) in the scene.

Note that all of these vectors are not normalised.

You'll get a 1.5KB .ZIP file.