1. Suppose the Centre of Projection is at (0,0,-1) and the viewplane is the plane z = 0. Let (x,y,z) be any point.
Let C = (0,0,-1), O = (0,0,0), P = (x,y,z) and B be the perpendicular projection of P on the XZ plane. Let Q(x',y',0) be the point of projection of the ray CP with the z=0 plane. Then triangles COQ and CBP are similar. Therefore: OQ/CO = PB/CB and hence y'/(1) = y/(z+1). Therefore the projected point has coordinates: x' = x/(z+1), y' = y/(z+1), z = 0.
The equation is given by: x(t) = tx, y(t) = ty, z(t) = -1 + t(z+1). We require the point where this intersects the plane z = 0. This occurs when all these equations are simultaneously satisfied, that is when z(t) = 0, ie, -1 + t(z+1) = 0, and hence when t = 1/(z+1). Substituting this into x(t), y(t) and z(t) we get the point (x/(z+1), y/(z+1), 0), as required.
2. Suppose there is a pyramid centered at the origin, with base coordinates at (1,0,0), (0,1,0), (-1,0,0), (0,-1,0) and of height 2. The pyramid is rendered with hidden surfaces removed. Define viewing parameters so that the projection of the pyramid will be:
For each image there are many possible views. To get a square with a diagonal cross we need to be looking down on the pyramid. Therefore we could use: VRP = (0,0,0) VPN = (0,0,-1) VUV = (1,1,0) COP = (0,0,-a), a > 0.
Here we need to be looking face on one of the sides: VRP = (0,0,0) VPN = (1,1,0) VUV = (0,0,1) COP = (0,0,-a), a > 0.
In this case we need to be looking straight onto an edge that joins two of the triangular faces (eg, look straight down the y axis): VRP = (0,0,0) VPN = (0,1,0) VUV = (0,0,1) COP = (0,0,-a), a > 0.
3. Suppose we have the following specification for a view:
VRP = (0,0,0)
VPN = (1,1,0)
VUV = (0,0,1)
Find the matrix M that transforms points from WC to VC. Normalise the VPN to get n = VPN/|VPN|. |VPN| = sqrt(2) = s (say). Then n = (1/s, 1/s, 0). u = (n x VUV) / |n x VUV| n x VUV = (1/s, -1/s, 0). This already has norm 1. v = u x n = (0,0,1). The 3 columns of u, v and n give the 3*3 matrix (R) in the top left corner of M. The first 3 elements of the 4th row are given by -qR, where q = VRP. But VRP = 0. Therefore the required matrix is: 1/s 0 1/s 0 -1/s 0 1/s 0 0 1 0 0 0 0 0 1
4. A camera is oriented so that it is "looking" along the line joining (x0,y0,z0) to (x1,y1,z1). The VUV is (0,0,1). The camera is to move along this line starting from (x0,y0,z0) until it reaches the other end, in N equal steps, taking a "shot" at the starting point and then at each step. Write a fragment of code to capture such a sequence of views.
Since the camera is looking along the line (x0,y0,z0) to (x1,y1,z1) we may take VPN = (x1-x0, y1-y0, z1-z0), and assume that COP is along negative N axis (0,0,-a) (a>0). The equation of the path along which the camera moves is p0 + t(p1-p0) where pi = (xi,yi,zi), and t varies from 0 to 1. We must divide this into N equal steps, ie, t = 0, 1/N, 2/N, ..., (N-1)/N, 1 will give the various points along the path. double inc = 1.0/N; double x = x0, y = y0; z = z0; double dx = (x1-x0)*inc, dy = (y1-y0)*inc; dz = (z1-z0)*inc; /*set up camera parameters, including VRP = (x,y,z)*/ clickCamera(); /*establishes all the parameters and computes matrices etc*/ displayEverything(); for(i=1; i<=N; ++i){ x += dx; y += dy; z += dz; setVRP(x,y,z); clickCamera(); displayEverything(); }5*. This is similar to the previous question. The camera is to move completely around a unit circle which is centred at the origin, at height h, and the orientation of the view is such that the camera is always "looking" at the origin. Write a fragment of code to capture such a sequence of views.