APPENDIX B

Equations

This appendix describes some important formulas and matrices referred to in the text.

B.1 3D Vectors

image

B.1.1 Spherical Coordinates

Given a point specified in Cartesian coordinates (x, y, z)T, the spherical coordinates (ρ, θ, φ) consisting of a length and two angles are

image

Given length ρ, azimuth angle φ, and elevation angle θ (assuming y is up) the Cartesian coordinates of the corresponding unit vector are

image

For unit vectors, ρ is equal to 1.

B.1.2 Linear Interpolation of 3D Vectors

Each vector component is interpolated separately, and then the resulting interpolated vector is renormalized. Renormalization is required if the interpolated vectors need to have unit length. Linearly interpolating a vector V using a single parameter α along a line with vectors A and B at the endpoints:

image

Linearly interpolating a vector V using two barycentric parameters α and β over a triangle with vectors A, B, C at the vertices:

image

Note: When using linear vector interpolation care must be taken to handle or report the case where one or more vector components interpolate to zero or a number so small that an excessive amount of accuracy is lost in the representation. In cases where linear interpolation is inadequate, spherical interpolation (SLERP) using quaternions may be a preferable method.

B.1.3 Barycentric Coordinates

Given a triangle with vertices A, B, C, the barycentric coordinates of the point P inside triangle ABC are α, β, γ, with P = αA + βB + γC and α + β + γ = 1. Let area (XYZ) be the area of the triangle with vertices X, Y, Z. Then

image

and the barycentric coordinates are the ratios of the areas of the subtriangles formed by the interior point P to the entire triangle ABC:

image

B.2 Projection Matrices

B.2.1 Orthographic Projection

The call glOrtho(l, r, b, t, u, f) generates R, where

image

R is defined as long as lr, tb, and nf.

B.2.2 Perspective Projection

The call glFrustum(l, r, b, t, n, f) generates R, where

image

R is defined as long as lr, tb, and nf.

B.2.3 Perspective z-Coordinate Transformations

The z value in eye coordinates, zeye, can be computed from the window coordinate z value, zwindow, using the near and far plane values, near and far, from the glFrustum command and the viewport near and far values, farvp and nearvp, from the glDepthRange command using the equation

image

The z-window coordinate is computed from the eye coordinate z using the equation

image

B.2.4 Alternative Perspective Projection

The call gluPerspective(fovy, ar, n, f) generates R, where

image

where image. R is defined as long as ar ≠ 0, sin(fovy) ≠ 0, and nf.

B.3 Viewing Transforms

The call gluLookat(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz) generates V, where

image

where image, and u = n × s. Or equivalently, image, and s = u × n.

B.4 Modeling Transforms

B.4.1 Scaling

The call glScalef(sx, sy, sz) generates S, where

image

B.4.2 Translation

The call glTranslatef(tx, ty, tz) generates T, where

image

B.4.3 Rotation

The call glRotatef(θ, Vx, Vy, Vz) generates R, where

image

and

image

image

B.5 Parallel and Perpendicular Vectors

Given two vectors A, B, the portion of A parallel to B is

image

and the proportion of A perpendicular to B is AB = A − AimageB.

B.6 Reflection Vector

Given a surface point p, a unit vector, N, normal to that surface, and a vector, U, incident to the surface at p, the reflection vector, R, exiting from p is

image

If U′ is exiting from the surface, U= − U and

image

B.7 Lighting Equations

In single-color lighting mode, the primary and secondary colors at surface point Ps are computed from n light sources as

image

In separate specular color mode, the primary and secondary colors are computed from n light sources as

image

where

em, am, dm, and sm are the material emissive, ambient, diffuse, and specular reflectances

asc is the scene ambient intensity

image, and image are the ambient, diffuse, and specular intensities for light source i

shi is the specular exponent for light source i

atti is the distance attenuation for light source i

image

where,

di is the distance between the surface point and light source i

image

image is the constant attenuation for light source i

image is the linear attenuation for light source i

image is the quadratic attenuation for light source i

spoti is the spotlight attenuation for light source i

image

where

sdi is the spotlight direction unit vector for light source i

sei is the spotlight exponent for light source i

coi is the spotlight cutoff angle for light source i

N is the surface normal unit vector Li is the unit vector from the surface point to light source i, image

Hi is the half-angle vector between the vectors from the surface point to the eye position (Pe), and the surface point and and light source i

image

fi is the self-occlusion discriminator for light source i

image

B.8 Function Approximations

B.8.1 Taylor Series Expansion

The Taylor series expansion of a function f(x) about the point a is

image

where f(j) denotes the jth derivative of f(x). The Maclaurin series expansion is the special case of the Taylor series expansion about the point a = 0.

B.8.2 Newton-Raphson Method

The Newton-Raphson method for obtaining a root of the function f(x) uses an initial estimate x0 and the recurrence

image (B.1)

The approximation for the reciprocal of a number a is the root of the equation f(x) = 1/x−a. Substituting f(x) in Equation B.1 gives

image

and the reciprocal square root of a number a is the root of the equation f(x) = 1/x2a. Substituting f(x) in Equation B.1 gives

image

B.8.3 Hypotenuse

A rough approximation of the 2D hypotenuse or length function image suitable for level-of-detail computations (Wu, 1988), is

image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.202.209