Sale!

CSCI 1180 Assignment 3 solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (2 votes)

In this assignment, you will use Matlab to show how the appearance of a 3D object changes as a
result of rotation (assuming that the distance to the object is constant, and large as compared to
the size of the object).
We will greatly simplify the problem by limiting it to convex polyhedra. The advantage of using
convex polyhedra is that it greatly simplifies the problem of determining what parts of the surface
are visible; a face of a convex polyhedron is visible if the normal to the face points toward the viewer.
The assigment is to write a function DrawRotatedPolyhedron(M,P). The input parameters are M, a
3×3 rotation (orthogonal) matrix, and P, a data structure representing a convex polyhedron. What
the function does is to draw a two-dimensional picture of P after rotation by M in a form to be
described below.
The input data structure representing of an n-face polyhedron P is a cellular array of size n, where
each cell is a face of the polyhedron. A face of the polyhedron with k vertices is a 3 × k array where
each column of the array contains the coordinates of the vertices. The columns are in counterclockwise order, as viewed by someone outside the solid looking at the face.
For example, the unit cube is represented as a cellular array { X1,X2,Y1,Y2,Z1 Z2 } where X1 is the
face at the low end of the x-axis, X2 is the face at the high end of the x-axis, and so on. Specifically,
X1 =


0 0 0 0
0 0 1 1
0 1 1 0

 X2 =


1 1 1 1
0 1 1 0
0 0 1 1

 Y 1 =


0 1 1 0
0 0 0 0
0 0 1 1


Y 2 =


0 0 1 1
1 1 1 1
0 1 1 0

 Z1 =


0 0 1 1
0 1 1 0
0 0 0 0

 Z2 =


0 1 1 0
0 0 1 1
1 1 1 1


This and other shapes are defined as scripts in file polyhedra.m. The function EulerRotation(Psi,Phi,Theta)
generates the 3D rotation with Euler angles Psi, Phi, Theta. These can be found in the course code
library, linked from the course web site.
The picture of the shape will reflect the appearance of the rotated shape as seen from below; thus,
the projection of the faces that are visible below onto the x-y plane (see figure). The picture will
show (1) the visible vertices and edges (2) in the center of each face, the projection of a small circle
around the center (which will project as an ellipse).
Constructing this picture involves the following steps:
• Apply the matrix M to each of the points in P, generating a new polyhedron P

. (Since the
absolute position of of the polyhedron does not matter, you can use natural coordinates and
a 3 × 3 rotation matrix rather than homogeneous coordinates and a 4 × 4 matrix.)
• Exclude faces that are not visible from below. To do this, compute the outward normal to
each face, and exclude any face whose normal has a positive z-component. To find the outward
normal to a face, choose any three consecutive vertices of the face a, b, c; the cross-product
(c − b) × (a − b) is the outward normal.
• Project the vertices and edges onto the x−y plane simply by ignoring the z coordinate. Draw
these in the picture.
1 CSCI 1180
• Compute the central circles on each visible face as follows:
– Compute the center o of the face as the average of the vertices of the face.
– Choose a radius r as half the distance from o to the nearest of the edges (use the formula
for the distance from a point to an edge discussed in class)
– Find two orthogonal unit-length vectors ˆu, vˆ in the plane of the face. (If a, b, c are vertices
in the face, then you can choose dir(b − a) as one and the perpendicular from c to line
ab as the other.)
– Compute points on the circle in 3D as o + r cos(2πt/N)ˆu + r sin(2πt/N)ˆv for t = 0 . . . N.
– Project these points onto the x − y plane by ignoring the z-coordinate, and connect the
points to plot the ellipse.
2 CSCI 1180