This homework has separate handouts for the written part:
and the programming part:
One more input file for your testing pleasure:
Check here for any updates to the hw4b description
There is a bug in the framework code - changes need to be made on lines 64, 67, and 68 of Sphere.java. All of the lines of code make an assignment to the variable B, and the expression that is assigned to B has a "/2.0" at the end of it. This expression needs to be divided by "/(2.0*A)". Make sure to put in the parentheses!
transformVector
and transformPoint
.
Read the handout's section on helpful hints... see if that makes anything clearer.
Again, my apologies. The handout is wrong, and the parser is not. Use the "Transform" keyword, not "Transformation".
Ok, my apologies for this one. The numbers that get handed to
Surface.rotateBy()
will be exactly as they are in the file. The
Parser
doesn't do anything intelligent with numbers, it simply
puts what it reads where it ought to go. The methods in Transformation
should expect to receive angles in radians only. Thus, it is up to the
person calling the Transformation
methods to make sure that
they use radians as angles. We will be specifying rotations in degrees in our
input files - these are just infinitely more readable. You need to make sure
that you account for this in Surface.rotateBy()
then. Use the
Math.PI
constant in converting numbers. A quick reminder for
those of you who get confused (as I do):
Instantiating objects in Java is a good deal more expensive than one might
think. This is done for run time safety. When a programmer is potentially
instantiating many objects per pixel, and is rendering from a few thousand to
a few million pixels though, this can become very inefficient. The use of an
output parameter can give the programmer using the Transformation
class a way of specifying where the result of a matrix operation should be put.
This is done in lieu of returning a newly instantiated object. If the output
parameter is null
, then it is often the case that the result
should be returned. If there is no return value, and the output parameter is
null
, then this is an error.
Take Transformation.leftProduct()
as an example. There are three
versions of this function:
Transformation leftProduct(Transformation input)
void leftProduct(Transformation input, Transformation output)
void leftCompose(Transformatoin input)
The first version will take in a single Transformation
as input.
Let's call the matrix represented by the input Transformation
B,
and the matrix represented by this
Transformation
A.
The first method should return a newly instantiated Transformation
that represents the matrix equal to B*A.
The second version will take in two Transformation
s. Use the same
naming convention as above. This second method should store the
Transformation
object that represents B*A in the output parameter.
This output parameter will not be null
.
The last version of this method will essentially perform the *= operation.
After its execution, this
=B*this
.
Another form of method calls exists in the Transformation
class.
This is where the output parameter can be null
and a return
value exists. In this case, the result is stored in output, and the result is
returned. If output is null, the value is still returned.
Transformation.new{Scale|Translate}()
. The new
handout has been corrected.
Transformation.new{X|Y|Z}Rotation()
. The new
handout has been corrected.