Wednesday, February 6, 2013

The most important tool in M&S toolbox:

"All models are wrong, some of them are useful"
- George Box

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:
  • c : center of the rectangle
  • u, v : normalized vectors that define the extent direction of the rectangle from the center
  • eU, eV : extent values.
 For a given 3D point p, first I need to find the distance of p to the border of the rectangle on the rectangle's local coordinate system. In Mathematica code, this translates to:
d = p - c;
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]];
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:

 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]];
Return[Sqrt[(du^2 + dv^2) + s^2]];
This results in the 3D distance function of an arbitrary rectangle:

Monday, January 28, 2013

#SitesILike: OverAPI CheatSheet Repository

OverAPI has obtained a mission to collect all information technology related cheat sheets into a single point. The technologies are ordered from A to Z. It is possible to find over 200 technologies, tools, applications, ...etc.