Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement midpoint displacement method to generate a surface and then move our v

ID: 3592676 • Letter: I

Question

Implement midpoint displacement method to generate a surface and then move our viewpoint, rather than the surface, to look at it. The program needs to use this algorithm to generate a surface and then modify the shaders to display the surface from different viewpoints. The commands are:

N -- view from the north. Position = (0.0, 5.0, -10.0)

S -- view from south. Position = (0.0, 5.0, 10.0)

E -- view from east. Position = (10.0, 5.0, 0.0)

W -- view from west. Position = (-10.0, 5.0, 0.0)

A -- view from above. Position = (0.0, 11.0, 0.0)

B -- view from below. Position = (0.0, -11.0, 0.0)

Enable depth testing to handle hidden surfaces properly.   The value for H should be input. The normal equation for the displacement is:

displacement = gaussianRV (0,1) * [1/(2^2*H*(i-1))]

Where i is the iteration number (starts at 1) and H is the Hurst exponent (between 1.0 and 2.0). Source code and shaders are required for the program.

Explanation / Answer

def displace ( points, max_disp ): last_point = points[0] new_points = [ last_point ] for next_point in points[1:]: midpoint_x = 0.5 * ( last_point[0] + next_point[0] ) midpoint_y = 0.5 * ( last_point[1] + next_point[1] ) midpoint_y += random.uniform( -max_disp, +max_disp ) new_points.append( (midpoint_x, midpoint_y) ) new_points.append( next_point ) last_point = next_point return new_points # initialize the endpoints points = [ (0, 300), (window_width, 300) ] # set the initial displacement range and scaling factor max_disp = 100 scale = 0.5 # repeat the displacement process 10 times for i in xrange(0, 10): points = displace( points, max_disp ) max_disp *= scale

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote