"All models are wrong, some of them are useful"- George Box
Wednesday, February 6, 2013
The most important tool in M&S toolbox:
3D Distance Function of a Rectangle
Signed distance functions are useful tools in solving many computer graphics and computational geometry problems. I use them to implement an enrichment technique to overcome some of the problems that I face when trying to reconstruct implicit surfaces. The technique is based on Barbieri et al.'s "A new weight-function enrichment in meshless methods for multiple cracks in linear elasticity" paper.
In my work, I use rectangular surfaces in the 3D space as the separating entity between two subsets of points. I don't want these two subsets to influence each other in weighted averaging operations, so I place a rectangular dividend in-between. Let's define a rectangle by these variables:
Now, I need to combine this information with the distance of the point to the rectangle in the rectangle's normal direction. This is simply achieved by taking the dot product of the d vector with the normalized normal vector of the rectangle.
In my work, I use rectangular surfaces in the 3D space as the separating entity between two subsets of points. I don't want these two subsets to influence each other in weighted averaging operations, so I place a rectangular dividend in-between. Let's define a rectangle by these variables:
- c : center of the rectangle
- u, v : normalized vectors that define the extent direction of the rectangle from the center
- eU, eV : extent values.
d = p - c;If I go deeper into this code, when I take the dot product of d with u and v, essentially I obtain the coordinate of the projection of p onto the plane that the rectangle lies on in terms of the rectangle's local coordinate system. Other absolute value stuff are there because I want the function to have a value of 0 inside the rectangle and a positive value outside of the rectangle. When I have the contour plot of this function with Mathematica, I obtain something like this:
dist = Abs[Dot[d, u]] - eu;
du = Abs[dist] + dist;
dist = Abs[Dot[d, v]] - ev;
dv = Abs[dist] + dist;
Return[Sqrt[du^2 + dv^2]];
Now, I need to combine this information with the distance of the point to the rectangle in the rectangle's normal direction. This is simply achieved by taking the dot product of the d vector with the normalized normal vector of the rectangle.
s = Abs[Dot[d, n]];This results in the 3D distance function of an arbitrary rectangle:
Return[Sqrt[(du^2 + dv^2) + s^2]];
Subscribe to:
Posts (Atom)

