Question: I need help programing this in C please. computeDiffuse - Compute diffuse lighting term 1 Finclude In computer graphics one component of incorporating lights into

I need help programing this in C please.

I need help programing this in C please. computeDiffuse - Compute diffuse

computeDiffuse - Compute diffuse lighting term 1 Finclude In computer graphics one component of incorporating lights into a scene is the diffuse term which is governed by Lambert's law This term is computed by normalizing two vectors known as the normal and incident light, finding the dot product of these vectors and clamping the result to be strictly non-negative 3 /I Vector definition 4 struct Vector f double x; double y; double z; 6 The dot product of two vectors given by vi-(X1.y1,Z1) and v2- (x2.y2.Z2) is given by 8 10 I/ Normalize function 11 struct Vector normalize(struct Vector v) 12 struct Vector v_n; double mag 0.0; mag sqrt (v.x*v.x v.y v.y v.z v.z) if (mag > 0) Write a function called computeDiffuse that takes two parameters 1. The first parameter is a Vector struct for the normal 2. The second parameter is a Vector struct for the incident 14 15 16 light 18 19 20 21 v_n.z V.z/mag; else The function should return a double value for the diffuse term Hints vn.y 0.0; Declare a variable whose type is the return type (double) The last statement in the body of the function should return the value of this variable 23 24 25 26 27 28 II TODO: Add function definition 29 . The Vector struct is provided return v n; Normalize the vectors using the provided normalize() function . If the result of the dot product is negative, the value should be set to zero Author: David Babcock License: Creative Commons Attribution-ShareAlike 3.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!