Transforming implicit surface (distance field) and their gradient

\( \renewcommand{\vec}[1]{ \mathbf{#1} }  \)
Let \( f:\mathbb R^3 \rightarrow\mathbb R\) be any distance field. We can transform any implicit surface \( f(x,y,z) = c\) with a 4x4 transformation matrix as follows:

$$ \hat f(\vec p) = f( \mathbf T^{-1} \vec p)$$


Sometimes you need to compute the normal of an implicit surface. You usually do this using the gradient \(\nabla f\) which needs to be transformed as well. Similar to the normal of a mesh use the inverse transpose of \( \mathbf T \):

$$ \hat{ \nabla f}(\vec p) = \left ( \mathbf T^{-1} \right )^{T} . \nabla f (  \mathbf T^{-1}  \vec p )$$


float transformed_value_and_gradient(Point pos, Vec3& grad)
    Point p = T.inverse() * pos;
    float field_values = distance_field(p, grad); // original field function value
    grad = T.inverse().transpose() * grad;
    return field_values;

Special transformations


No comments

All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Anti-spam question: