Errata for the First Edition

There are some errors/typos/bugs found from the 1st edition of the book. Below are the list of such errors either found by myself or fellow readers.

Page 26

Reporter: Marc Le Renard

The description length(a*)=a.b is only true if vector b is unit-sized, else a.b = length(a*) x length(b).

Page 44

Reporter: Marc Le Renard

There should be x. before x , y , z in the std::sin formula.

Page 90

Reporter: Marc Le Renard

The y-position is clamped to 0 but in the code the y-position is clamped to -7.0.

Page 94

Reporter: Marc Le Renard

From Figure 1.51, the formula should be p = \rho g h + p_{atm} instead of p = p g h + p_{atm}

Page 184

There was a bug in the code. The fixed version is shown below:

auto u = velocity->uAccessor();
auto uPos = velocity->uPosition();

velocity->parallelForEachUIndex([&](size_t i, size_t j, size_t k) {
    Vector3D pt = uPos(i, j, k);
    if (isInsideSdf(_colliderSdf.sample(pt))) {
        Vector3D colliderVel = collider()->velocityAt(pt);
        Vector3D vel = velocity->sample(pt);
        Vector3D g = _colliderSdf.gradient(pt);
        if (g.lengthSquared() > 0.0) {
            Vector3D n = g.normalized();
            Vector3D velr = vel - colliderVel;
            Vector3D velt = projectAndApplyFriction(
                velr, n, collider()->frictionCoefficient());

            Vector3D velp = velt + colliderVel;
            uTemp(i, j, k) = velp.x;
        } else {
            uTemp(i, j, k) = colliderVel.x;
        }
    } else {
        uTemp(i, j, k) = u(i, j, k);
    }
});

u.parallelForEachIndex([&](size_t i, size_t j, size_t k) {
    u(i, j, k) = uTemp(i, j, k);
});