cg_chapter2

2.5 Curves and Surfaces

2.5.1 2D Implicit Curves

implicit equation $f(x,y)=0$

2.5.2 The 2D Gradient

$nabla f(x,y)=(frac{partial f}{partial x},frac{partial f}{partial y})$
normal vector: vector perpendicular to the tangent vector of the curve at that point
gradient points indicate the direction of the f(x,y) > 0 region

2.5.5 Implicit Planes

$(vec p- vec a) cdot vec n = 0 $
$vec n = (vec b - vec a)times(vec c - vec a)$

2.5.7 3D Parametric Curves

a spiral aroung the z-axis:
$ x=cost $
$ y=sint $
$ z=t $


2.6 Linear Interpolation

points are connected by straight line segments
$f(x) = y_{i+1} + frac{x-xi}{x{i+1}-xi}(y{i+1}-y_i)$
$(1-t)A+B$


2.7 Triangles

2.7.1 2D Traingles

area=$frac{1}{2} begin{vmatrix} x_b-x_a & x_c - x_a y_b-y_a&y_c-y_a end{vmatrix}$

This area will have a positive sign if points a,b,c are in counterclockwise order and a negative sign,otherwise

  • barycentric coordinate
    $mathbf{p} = mathbf{a} + beta(mathbf{b}-mathbf{a}) + gamma(mathbf{c} - mathbf{a}) $
    $mathbf{p} = (1-beta-gamma)mathbf{a} + beta mathbf{b} + gamma mathbf{c} $
    $mathbf{p} = alpha mathbf{a} + beta mathbf{b} + gamma mathbf{c}$ $alpha+beta+gamma=1$

    A particular nice feature of barycentric coordinates is that a point p is insde the triangle formed by a,b,c if and only if
    $0 < alpha < 1$
    $0 < beta < 1$
    $0 < gamma < 1$
    if one of the coordinates is zero and the other two are between zero and one, then you are on an edge, If two of the coordinate are zeor, then the other is one, and you are at a vertex

  • how to compute?
    $begin{bmatrix} x_b-x_a&x_c-x_a y_b-y_a&y_c-y_aend{bmatrix} begin{bmatrix}beta\gammaend{bmatrix}=begin{bmatrix}x_p-x_a y_p-yaend{bmatrix}$
    $beta = frac{f
    {ac}(x,y)}{f_ac{x_b,y_b}}$
    $beta = frac{(y_a-y_b)x + (x_b-x_a)y + x_ay_b - x_by_a}{(y_a-y_b)x_c + (x_b-x_a)y_c + x_ay_b - x_by_a}$
    $A=A_a+A_b+A_c$ is the area of the traingle
    $alpha=A_a/A$
    $beta=A_b/A$
    $gamma=A_c/A$

    This rule still holds for points outside the triangle if the areas are allowed to be signed. note that these are signed areas and will be computed correctly as long as the same signed area computation is used for both A and subtriangles

2.7.2 3D Triangles

$mathbf{p} = (1-beta-gamma)mathbf{a} + betamathbf{b} + gammamathbf{c}$
$mathbf{n=(b-a)times(c-a)}$
$area=mathbf{frac{1}{2}|(b-a)times(c-a)|}$
$alpha=mathbf{ frac{n cdot n_a}{|n|^2}}$
$beta=mathbf{ frac{n cdot n_b}{|n|^2}}$
$gamma=mathbf{ frac{n cdot n_c}{|n|^2}}$