Docsity

Computer Graphics Homework 1, ECSE-4750, RPI, Spring 2005 - Prof. W. R. Franklin, Assignments of Computer Graphics

Toggle sidebar
bg1
Homework 1, due Jan 26 in lab
Computer Graphics (ECSE-4750), RPI
Spring 2005
1. Find the eigenvalues and eigenvectors of this matrix:
.4 .6
-.6 .4
Suggested tools include Matlab, Maple, or doing it by hand.
[V, E] = eig(A) with MATLAB
Eigenvectors: V = [ 0-0.7071i 0+0.7071i
0.7071 0.7071]
Eigenvalues: E =[ 0.4000 + 0.6000i 0
0 0.4000 - 0.6000i]
2. Consider these 3-D vectors: A=(1,2,3), B=(4,5,6), C=(7,8,9). Compute:
i. A.BxC
BxC=[-3 6 -3]
A.BxC = 0
ii. AxB.C
AxB=[-3 6 -3]
AxB.C = 0
3. This is another a test of your linear algebra knowledge. Feel free to refer
to books to find the correct formulae.
Suppose that we have a plane in 3-D thru the points A(1,0,1), B(0,1,0),
and C(0,0,1).
pf3
pf4
pf5

Partial preview of the text

Download Computer Graphics Homework 1, ECSE-4750, RPI, Spring 2005 - Prof. W. R. Franklin and more Assignments Computer Graphics in PDF only on Docsity!

Homework 1, due Jan 26 in lab

Computer Graphics (ECSE-4750), RPI

Spring 2005

1. Find the eigenvalues and eigenvectors of this matrix:

Suggested tools include Matlab, Maple, or doing it by hand.

[V, E] = eig(A) with MATLAB

Eigenvectors: V = [ 0-0.7071i 0+0.7071i

0.7071 0.7071]

Eigenvalues: E =[ 0.4000 + 0.6000i 0

0 0.4000 - 0.6000i]

2. Consider these 3-D vectors: A=(1,2,3), B=(4,5,6), C=(7,8,9). Compute:

i. A.BxC

BxC=[-3 6 -3] A.BxC = 0

ii. AxB.C

AxB=[-3 6 -3] AxB.C = 0

3. This is another a test of your linear algebra knowledge. Feel free to refer

to books to find the correct formulae.

Suppose that we have a plane in 3-D thru the points A(1,0,1), B(0,1,0),

and C(0,0,1).

i. What is its equation, in the form ax + by + cz + d =0?

ii. Consider the line L thru the points O(0,0,0) and P(1,1,1). Where

does this line intersect the plane?

i) AB x BC = [-1 1 -1] x [0 -1 1] = [0 1 1] Therefore, ax + by + cz + d =0 is y+z+d=0. With point A(1, 0, 1), d= -1. Equation is y+z-1=0.

ii) line L is x=y=z, therefore the intersection is (0.5, 0.5, 0.5).

4. This is a test of whether you know enough C for this course. The following

code will copy string s^ to array t, provided that a few erroneous lines are

corrected. What are the corrections and proper initializations?

char s="Hello!"; char t[6]; char p, q; p=s; q=t; for (;q++ = *p++;);

Correction:

**char *s="Hello!"; char t[7]; char p, q; p=s; q=t; for (;q++ = p++;);

5. If we're going to be learning complicated graphics in this course, it

behooves us still to be able to do the simple things. So, this exercise is to

plot the ship NCC1701.

Here is a compressed file of 3,958 triangles defining the USS Enterprise. It

looks like this when uncompressed with gunzip:

1.431000 0.505000 0. 1.572000 0.505000 0. 1.287000 0.505000 0. 1.431000 0.505000 0.

I also plotted it in Matlab. First I wrote a program to reformat the data as 3 files: x.dat, y.dat, z.dat.

// Time-stamp: </wrf/graphics/hw1/refmt.cc, Mon, 24 Jan 2005, 16:01:51 EST, wrf AT ecse.rpi.edu>

// reformat ncc1701.data to be useful for Matlab fill3.

// W. Randolph Franklin

#include #include <boost/multi_array.hpp> #include #include

using namespace std; using boost::array;

typedef array<double,3> Tpoint;

int main() {

Tpoint p; vector indata;

vectorx; vectory; vectorz; int n(0);

string files[3]={"x.dat","y.dat","z.dat"};

ifstream instream("ncc1701.data"); if (!instream) { cout << "ERROR: can't open file ncc1701.data" << endl; exit(1); }

while (instream >> p[0] >> p[1] >> p[2]) { n++; indata.push_back(p); }

int m=indata.size();

if (m%4 !=0) { cerr << "ERROR number of points is not a multiple of 4." << endl; exit(1); }

for (int xyz=0; xyz<3; xyz++) { ofstream outstream(files[xyz].c_str()); if (!outstream) { cout << "ERROR: can't open output file" << endl; exit(1); } for (int k=0; k<3; k++) { for (int j=0; j<m; j+=4) outstream << indata[j+k][xyz] << ' '; outstream << endl; } } }

Then I did this in Matlab:

load 'x.dat';