首页 >
> 详细

Notes and hints for Assignment 3

Ray tracing onto a plane

The equation for a planar 2D surface oriented into 3D space is:

a(x − xc) + b(y − yc) + c(z − zc) = 0

where (xc, xc, xc) are the coordinates of the corner of the plane and (a, b, c) are the directional

components of the plane surface normal vector.

It is convenient to write this in vector form (note this will work in homogeneous as well as

Cartesian coordinates)

N · (P − Pc) = 0

A vector starting at point P0 and running through point P1 can be described parametrically

as P = P0 + t(P1 − P0)

We want the value of t such that this vector intersects the above plane. Substituting the

vector equation into the plane equation, and solving for t yields:

thit =

N · (Pc − P0)

N · (P1 − P0)

The coordinates in world space of the surface of the plane where the ray hits it, is then

simply

Psurface = P0 + thit(P1 − P0)

Note these are the coordinates where the ray hits anywhere on the planar surface. You will

need additional checks to see if the intersection is within the width and height that you have

defined for the plane.

The vector for the surface normal is just N as above.

Ray tracing onto the surface of a sphere

The equation for the surface of a sphere of radius r centred at (xc, yc, zc) is

(x − xc)

2 + (y − yc)

2 + (z − zc)

2 = r

A ray can be described parametrically by x = x0 + t(x1 − x0), y = y0 + t(y1 − y0), and

z = z0 + t(z1 − z0). Substitute these into the equation of a sphere, expand it out and gather

all the terms and one gets a quadratic equation in t for which we solve. Constructing the

quadratic equation this way is not difficult, but does involve some tedious algebra.

As with the plane, we can do all this using vector maths. In vector/point form the equation

of a sphere can be written:

(P − Pc) · (P − Pc) = r

2

As before, the ray shooting equation in vector form is:

P = P0 + t(P1 − P0)

Substituting this for P in the equation of a sphere

(t(P1 − P0) + P0 − Pc) · (t(P1 − P0) + P0 − Pc)

Here we have a dot product operation involving just two vectors (ie differences between

points). Let’s write

U = P1 − P0

V = P0 − Pc

Expanding we then have:

(U · U)t

2 + 2(U · V)t + V · V = r

This is a quadratic equation of the form at2 + bt + c = 0 which we need to solve for t. How

do we do it? Just recall your high school maths. In general there are two solutions for t

given by

You need to first look at the “discriminant” D = b

2 − 4ac.

• D < 0 no real solutions for t, ie the ray misses the sphere

• D = 0 one solution for t, the ray just grazes the sphere

• D > 0 two solutions for the sphere intersect, entry and exit

Given this, one can then get the coordinates for the ray entry into the sphere surface.

However, what about the surface normal vector? What property of spheres can one use to

get this?

Hints on matrix transformations

Recall from the lectures, to transform an object from local coordinate space to world coordinate

space, first we scale it, then rotate it, then displace it. This is done by a single matrix

transformation constructed from matrices for scalings, rotations, and displacement, ie

T = D(dx, dy, dz) · Rx(ψ) · Ry(θ) · Ry(φ) · S(sx, sy, sz)

Consider a plane modelled in local coordinates. This has its corner at the origin, has unit

width and height, and is located on the xy plane.

• What are the coordinates of the corner after being transformed into world space?

• What are the components of the surface normal of the plane in local space?

• What are the components of the surface normal after transforming to world space?

You are also asked to construct a matrix that does the inverse of the above—this matrix

will come in useful. How would you do this? You do NOT have to install a linear algebra

library to compute a matrix inverse. Just think through the steps you would have to take

to bring an object from world space back into local space.

Illumination model

The full local illumination model includes an ambient term plus diffuse and specular terms

for multiple light sources. In this assignment it is enough to consider a simplified model with

one light source and no ambient light. The local illumination model can then be written as

follows:

f = βN · L + (1 − β)(V · R)n

where β is the amount of mixing between the diffuse and specular terms and 0 ≤ β ≤ 1.

Note that N, L, and R are normalized vectors. The shading factor, f, is the scale factor

that is applied to the surface colour. You need to ensure that 0 ≤ f ≤ 1, ie check for negative

dot products.

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-23:00
- 微信：codinghelp

- 95-712留学生作业代做、代写java编程设计作业、代做polymorph 2019-10-18
- 代做ols留学生作业、代写r程序语言作业、代做r编程设计作业、代写linea 2019-10-18
- Sdgb 7844作业代做、R编程设计作业代做、代写markdown留学生作 2019-10-18
- 代写math4/68091作业、代做statistical Computin 2019-10-18
- Analytics留学生作业代做、代写data Visualisation作 2019-10-18
- 代写frt留学生作业、代写r语言作业、代做datasets课程作业、R编程设 2019-10-18
- 代做sta 442课程作业、代写effects Models作业、Pytho 2019-10-17
- Se 3316A作业代做、代写web Technologies作业、Java 2019-10-17
- 代写csi213留学生作业、代做data Structures作业、代写ja 2019-10-17
- Cse 325作业代写、C/C++编程设计作业调试、Program留学生作业 2019-10-17
- 代做fit2014留学生作业、代做c++课程设计作业、Information 2019-10-17
- Scm 460课程作业代做、代写r编程设计作业、代做r实验作业、代写data 2019-10-17
- 代写rad留学生作业、代做r, Matlab/C++编程语言作业、代写r课程 2019-10-17
- Comp5338作业代写、Sql程序语言作业调试、代写schema Desi 2019-10-17
- 代做159.20留学生作业、代写rle课程作业、Java编程设计作业调试、P 2019-10-17
- 代做gu4206/Gr5206作业、代写r程序语言作业、代写data留学生作 2019-10-16
- Fit2104留学生作业代做、代写sql语言作业、Sql编程语言作业调试、代 2019-10-16
- 代写glfrustum课程作业、代做python程序语言作业、代写java， 2019-10-15
- 代写software留学生作业、代做information Technolo 2019-10-15
- 31927留学生作业代做、Net Applications作业代写、C++程 2019-10-15