<div dir="ltr"><div>Hi Dr. Thompson,</div><div><br></div><div>I have finished supplementary documentation for the vtkFiltersBezier module. I think it's ready to be tested now.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 20, 2015 at 11:56 PM, Lin M <span dir="ltr"><<a href="mailto:majcjc@gmail.com" target="_blank">majcjc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Dr. Thompson,</div><div><br></div><div>I have added image based tests for almost all vtkFiltersBezier related class including BREP file reader, patch(simplicial) interpolation and point projection for both curve and surface example.</div><div><br></div><div>I will complete required documents soon.</div><div><br></div><div>Best,</div><div>Lin</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 8:23 PM, David Thompson <span dir="ltr"><<a href="mailto:david.thompson@kitware.com" target="_blank">david.thompson@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="auto"><div>Hi Lin,</div><div><br></div><div>It has been a while since we talked about that, and I am not sure from looking at the method whether Pt is supposed to be the input or output. If the input, then it should be named something like coord instead of Pt. If the output, then you are correct, it should be a "double*" and the documentation should spell out how much memory it must point to. (Since in general the n-th derivative is a symmetric tensor of rank n, there are (n+1)(n+2)...(n+k-1)/(k-1) partial derivatives. This is related to Pascal's simplex. See <a href="https://en.wikipedia.org/wiki/Pascal%27s_pyramid#Parallels_to_Pascal.27s_triangle_and_Multinomial_Coefficients" target="_blank">https://en.wikipedia.org/wiki/Pascal%27s_pyramid#Parallels_to_Pascal.27s_triangle_and_Multinomial_Coefficients</a> and <a href="https://en.wikipedia.org/wiki/Differential_of_a_function#Higher-order_differentials" target="_blank">https://en.wikipedia.org/wiki/Differential_of_a_function#Higher-order_differentials</a> .)</div><div><br></div><div><span style="background-color:rgba(255,255,255,0)">It is fine to have different methods for curves, surfaces, and volumes for now. As you can see in the links above, the general pattern is that the n-th total derivative is a tensor of all possible combinations of partial derivatives with respect to the 1, 2, or 3 parametric coordinates. Call the parametric coordinates r_i for i in {1, 2, 3} and say we are taking the n-th derivative of f. Then Python code to compute one possible ordering of the partial differentials in the output array would be</span></div><div><br></div><div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">def pdiff(i,n):</span></div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">    r=[]</span></div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">    if i == 1:</span></div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">        return [[n,],]</span></div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">    for x in range(n+1):</span></div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">        for y in pdiff(i-1,n-x):</span></div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">            r.append(y+[x,])</span></div><div style="font-weight:bold"><span style="background-color:rgba(255,255,255,0)">    return r</span></div></div><div><br></div><div>which returns a list of i-tuples that all sum to n. For example</div><div><br></div><div><span style="background-color:rgba(255,255,255,0)">pdiff(2,1) returns </span><span style="font-weight:bold;background-color:rgba(255,255,255,0)">[[1, 0], [0, 1]]</span></div><div>pdiff(2,2) returns <span style="font-weight:bold;background-color:rgba(255,255,255,0)">[[2, 0], [1, 1], [0, 2]]</span></div><div><br></div><div><span style="background-color:rgba(255,255,255,0)">pdiff(3,1) returns </span><span style="font-weight:bold;background-color:rgba(255,255,255,0)">[[1, 0, 0], [0, 1, 0], [0, 0, 1]]</span></div><div><span style="background-color:rgba(255,255,255,0)">pdiff(3,2) returns</span><span style="font-weight:bold;background-color:rgba(255,255,255,0)"> [[2, 0, 0], [1, 1, 0], [0, 2, 0], [1, 0, 1], [0, 1, 1], [0, 0, 2]]</span></div><div><span style="color:rgb(50,255,0);font-family:Courier;font-size:16px;font-weight:bold"><br></span></div><div>However, really only the first (Jacobian, a vector) and second (Hessian, a symmetric 3x3 matrix with 6 unique entries) derivatives are used very much because (a) the number of terms grows very fast with increasing derivative and (b) the first 2 derivatives are used widely for root-finding and curvature computation but further derivatives are not.</div><span><font color="#888888"><div><br></div><div>    David</div></font></span><div><div><div><br></div><div>On Aug 17, 2015, at 22:40, Lin M <<a href="mailto:majcjc@gmail.com" target="_blank">majcjc@gmail.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div>Hi Dr. Thompson,</div><div><br></div><div>I found you left an interface for vtkBezierPatchAdaptro::EvaluateDeriv(double Pt[3], double* Paras, int d).</div><div>For 1-d curve, the derivative is always a 3*1 vector, but with the parametric dimension increasing, higher order derivatives will contain many points (it becomes matrix-by-vector differential). I can't figure out a generalized way to interpret this. That's why I declared functions to compute derivative for curve, surface and volume separately. Do you have any suggestions for that? Thanks!</div><div><br></div><div>Best,</div><div>Lin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 1:04 AM, David Thompson <span dir="ltr"><<a href="mailto:david.thompson@kitware.com" target="_blank">david.thompson@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Hi Lin,<br>
<span><br>
> I have some questions about the test.<br>
> 1. About simplicial interpolation. Should I test some simple cases (hard coded simple shape) or some shapes like the motorcycle?<br>
<br>
</span>Those are 2 different types of tests. (There are many; see <a href="http://stackoverflow.com/questions/437897/what-are-unit-testing-and-integration-testing-and-what-other-types-of-testing-s" target="_blank" rel="noreferrer">http://stackoverflow.com/questions/437897/what-are-unit-testing-and-integration-testing-and-what-other-types-of-testing-s</a> for some lists of test types). The first test (simple hard-coded shape) is a unit test and the second (test of both the reader, spline-to-patch class, and patch interpolation) is an integration test.<br>
<br>
Both are important, but since you already have an integration test for the motorcycle, I think a good set of unit tests for simplicial interpolation would be enough.<br>
<span><br>
> If it is the latter one, how to convert the rectangular patch to simpicial patch?<br>
><br>
</span>> 2. About point inversion. How to test it for the simpicial patch? I only implemented the point inversion for NURBS patch.<br>
<br>
If you didn't implement it, you can't test it. :-) However, if you know what you want the test to look like, you can write the test before you implement inversion and just leave it commented out with a note. Many people think this is how development should be done in the first place, since it forces you to consider how people will use what you write.<br>
<span><br>
> 3. About derivative computation. Should I just test them numerically? For example, given a shape and a parametric coordinate, test the result of our implementation with ground truth.<br>
<br>
</span>Again, since you are using the derivatives in code that is part of an integration, I think unit testing (as you suggest) is enough.<br>
<span><font color="#888888"><br>
        David</font></span></blockquote></div><br></div>
</div></blockquote></div></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>