Needing help with an assignment for my computer graphics cla

Needing help with an assignment for my computer graphics class, I am struggling with OpenGL and have been trying to work on this all week but I am just lost. I\'ve tried other answers on here but none of them work. Any help would be great appreciated :/

A stationary 3D scene is interesting, and much effort has been spent producing as accurate a scene as possible using various rendering techniques. However, the applications of a single-frame render are somewhat limited. In this assignment, we are going to introduce motion and interactivity to our scene. Using C++, OpenGL, and Microsoft Visual Studio, create a program that does the following:

Applies a transformation to an object that varies over time, using two of the following examples:

An object that travels back and forth along a line repeatedly

An object that moves in a circle

An object that continually rotates

An object that scales up and down repeatedly

Uses a camera class to control the display of the scene

Allows the user to reposition the camera in the scene using the arrow keys

Solution

~\'\'\'

def integLeft(a, b, f, nbins=10):
\'\'\'Return the integral from a to b of operate f victimization the mitt rule

>>> integLeft(0, 1, f, 4)
0.71875
\'\'\'
h = float(b-a)/nbins # enable input of whole number a and b
assert h > zero # warn if b not > a
assert type(nbins) == int
  
sum = 0.0
for n in range(nbins): # [0, 1, ... nbins-1]
add = add + h * f(a + n*h) # mitt rule

return sum
\'\'\'
The first issue you will notice regarding Python, is that there aren\'t any brackets and
semicolons or different punctuation to outline statements and code blocks. Thus
\"program structure\" is established by indentation. whereas this might seem to be a
bad plan to anyone World Health Organization has not tried Python, it truly is healthier for teaching
(and for knowledgeable programmers World Health Organization would possibly build easy blunders). The
interpreter catches indentation errors, and will not let the coed continue with
a refined eror as a result of a permed bracket is out of place. lecturers now not have
to nag students regarding correct vogue.

Notes on the code above:

1) Python contains a terribly versatile argument-passing syntax. If you embody a
\"default value\" with a parameter (nbins=10), that produces it a \"keyword\"
parameter. Keyword parameters area unit facultative in a very decision to the operate.

2) Python variables don\'t have any sort. Parameters a, b and f on top of area unit expected to
be 2 floats and a operate. whereas sort declarations would catch some errors,
Python expects the coder write express and complete checks in those
situations wherever defensive programming is vital (like user input).

The checks on top of do lots quite simply sort checking. They conjointly function
documentation. Students can learn early regarding sensible programming practices, if
teachers embody some dangerous inputs in their machine-controlled check cases. On the opposite
hand, if the stress is on learning algorithms, not programming, these tests
can be overlooked. Python permits that flexibility.
~\'\'\'

def integMid(a, b, f, nbins=10):
\'\'\'Return the integral from a to b of operate f victimization the center rule

>>> integMid(0, 1, f, 4)
0.828125
\'\'\'
h = float(b-a)/nbins
assert h > zero
assert type(nbins) == int
  
sum = 0.0
x = a + h/2 # initial center
whereas (x < b):
add += h * f(x)
x += h

return sum

def integTrap(a, b, f, nbins=10):
\'\'\'Return the integral from a to b of operate f victimization quadrangle rule

>>> integTrap(0, 1, f, 4)
0.84375
\'\'\'
h = float(b-a)/nbins
assert h > zero
assert type(nbins) == int
  
add = (h/2) * (f(a) + f(b)) # endpoints area unit special
for n in range(1, nbins): # [1, 2, ... nbins-1]
add += h * f(a + n*h)
  
return sum


if __name__ == \'__main__\':
\'\'\'
Everything from here down runs provided that this \"integration.py\" module is run
directly from the interpreter. Here is that the place for all the mussy \"overhead\"
needed to run tests and generate nicely-formatted output. The mess is unnoticed
if this module is foreign into another, as an example, to create this module half
of a library you would possibly decision to try and do integrations.
\'\'\'
def table_of_errors(a, b, f, exact):
\'\'\'
Print timings and a table of errors comparison these integration strategies to
a precise result. Show however the error decreases as o(1/nbins) or
o(1/nbins**2), reckoning on the strategy.
~\'\'\'
print
print \"nbins Left middle Trap\"

for nbins in [4, 40, 400]:
print \'%4s .9f .9f .9f\' the troubles (nbins,
integLeft(a,b,f,nbins), integMid(a,b,f,nbins), integTrap(a,b,f,nbins))
print
for nbins in [4, 40, 400]:
print \'%4s .9f .9f .9f\' the troubles (nbins,
integLeft(a,b,f,nbins) - actual,
integMid(a,b,f,nbins) - actual,
integTrap(a,b,f,nbins) - actual )
print

from time import time # from time module import time operate
t0 = time() # seconds
integLeft (0, 1, f, 1000)
t1 = time()
integMid (0, 1, f, 1000)
t2 = time()
integTrap (0, 1, f, 1000)
t3 = time()
  
print (\"Time for one thousand bins:\ .6f .6f .6f\" %
( (t1-t0), (t2-t1), (t3-t2) ) )


table_of_errors(0, 1, f, 5/6.)
\'\'\'
>>> table_of_errors(0, 1, f, 5/6.)

nbins Left middle lure
4 0.718750000 zero.828125000 zero.843750000
40 0.820937500 zero.833281250 zero.833437500
400 0.832084375 zero.833332812 zero.833334375

4 -0.114583333 -0.005208333 zero.010416667
40 -0.012395833 -0.000052083 zero.000104167
400 -0.001248958 -0.000000521 zero.000001042

Time for one thousand bins:
0.000865 zero.000763 zero.000814
\'\'\'
from doctest import testmod
testmod(verbose=True) # run the doctests when this module is run.
\'\'\'
Doctests serve 2 purposes:

1) They justify by example however your functions area unit referred to as.
2) They function \"unit tests\". If you ever build a amendment that breaks associate degree
existing check \"testmod\" can holler at you :>)
Don\'t let refined errors elapse. If a program is to fail, let it fail like a shot
and loudly.

Notes:
\"testmod\" needs the output to be precisely as within the example. we have a tendency to had to maneuver
the table_of_errors check outside of the operate (where testmod does not see it)
to allow for run-to-run variations within the timings.
~\'\'\'

Needing help with an assignment for my computer graphics class, I am struggling with OpenGL and have been trying to work on this all week but I am just lost. I\
Needing help with an assignment for my computer graphics class, I am struggling with OpenGL and have been trying to work on this all week but I am just lost. I\
Needing help with an assignment for my computer graphics class, I am struggling with OpenGL and have been trying to work on this all week but I am just lost. I\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site