Chris,

Can you document, i.e., add a NOTE comment, as to why 0.01 is more reasonable 
than RT_LEN_TOL?  Adding a #define above that function with the comment would 
help explain what that value means and/or why it's better than other values.  
Like if that's in uv-space, maybe that walks in increments that are 
approximately 1% linearly across the uv space?  If it's absolute valued, maybe 
it guarantees you'll find inflection points within 0.01mm accuracy (in which 
case it should change to 0.0005?  If it's meant to test curvature flatness and 
that's the dot product, then you could document that as well.

Whatever the reasoning, any time there is a "bare" number like that, it should 
be clearly documented even if only to say this number was pulled out of thin 
air but seems to work (hopefully not though).

At a glance, it looks like RT_DOT_TOL might be what you want to use (notice how 
it's documented in raytrace.h).

Cheers!
Sean


On Jul 19, 2012, at 2:42 AM, crdu...@users.sourceforge.net wrote:

> Revision: 51585
>          http://brlcad.svn.sourceforge.net/brlcad/?rev=51585&view=rev
> Author:   crdueck
> Date:     2012-07-19 06:42:39 +0000 (Thu, 19 Jul 2012)
> Log Message:
> -----------
> approx_bezier interval step size now varies with curvature. Step size is 
> small when curvature is large (more likely to deviate from approximation 
> arc). updated minimum step size for approx_bezier and bezier_inflection to a 
> more reasonable 0.001 instead of RT_LEN_TOL
> 
> Modified Paths:
> --------------
>    brlcad/trunk/src/librt/primitives/sketch/sketch_tess.cpp
> 
> Modified: brlcad/trunk/src/librt/primitives/sketch/sketch_tess.cpp
> ===================================================================
> --- brlcad/trunk/src/librt/primitives/sketch/sketch_tess.cpp  2012-07-19 
> 04:53:52 UTC (rev 51584)
> +++ brlcad/trunk/src/librt/primitives/sketch/sketch_tess.cpp  2012-07-19 
> 06:42:39 UTC (rev 51585)
> @@ -91,6 +91,7 @@
> HIDDEN bool
> bezier_inflection(const ON_BezierCurve& bezier, fastf_t& inflection_pt)
> {
> +    int sign;
>     fastf_t t, step, crv;
>     ON_3dVector d1, d2; // first derivative, second derivative
>     ON_3dPoint tmp;     // not used, but needed by Ev2Der
> @@ -99,10 +100,10 @@
>     bezier.Ev2Der(0, tmp, d1, d2);
>     crv = CURVATURE(d1, d2);
>     // maximum step size is 0.1, but decreases as |crv| -> 0 with minimum step
> -    // size RT_LEN_TOL
> -    step = fabs(crv) > 0.1 ? 0.1 : (fabs(crv) < RT_LEN_TOL ? RT_LEN_TOL : 
> fabs(crv));
> +    // size 0.01
> +    step = fabs(crv) > 0.1 ? 0.1 : (fabs(crv) < 0.01 ? 0.01 : fabs(crv));
> 
> -    int sign = SIGN(crv);
> +    sign = SIGN(crv);
> 
>     for (t = step; t <= 1.0; t += step) {
>         bezier.Ev2Der(t, tmp, d1, d2);
> @@ -112,7 +113,7 @@
>             inflection_pt = t;
>             return true;
>         }
> -        step = fabs(crv) > 0.1 ? 0.1 : (fabs(crv) < RT_LEN_TOL ? RT_LEN_TOL 
> : fabs(crv));
> +        step = fabs(crv) > 0.1 ? 0.1 : (fabs(crv) < 0.01 ? 0.01 : fabs(crv));
>     }
>     return false;
> }
> @@ -127,17 +128,24 @@
> approx_bezier(const ON_BezierCurve& bezier, const ON_Arc& biarc, const struct 
> bn_tol *tol, std::vector<ON_Arc>& approx)
> {
>     fastf_t t, step = 0.1;
> -    fastf_t err, max_t, max_err = 0.0;
> +    fastf_t crv, err, max_t, max_err = 0.0;
>     ON_BezierCurve head, tail;
> +    ON_3dPoint test;
> +    ON_3dVector d1, d2;
> 
>     // walk the bezier curve at interval given by step
>     for (t = 0; t <= 1.0; t += step) {
> -        err = fabs((bezier.PointAt(t) - biarc.Center()).Length() - 
> biarc.Radius());
> +        bezier.Ev2Der(t, test, d1, d2);
> +        err = fabs((test - biarc.Center()).Length() - biarc.Radius());
>         // find the maximum point of deviation
>         if (err > max_err) {
>             max_t = t;
>             max_err = err;
>         }
> +        crv = CURVATURE(d1, d2);
> +        // maximum step size is 0.1, but decreases as |crv| -> 1 with 
> minimum step
> +        // size 0.01
> +        step = 1.0 - fabs(crv) > 0.1 ? 0.1 : (1.0 - fabs(crv) < 0.01 ? 0.01 
> : 1.0 - fabs(crv));
>     }
> 
>     if (max_err + VDIVIDE_TOL < tol->dist) {
> @@ -225,6 +233,7 @@
>     } while (!rest.empty());
> }
> 
> +
> #define SKETCHPT(idx) sketch_ip->verts[(idx)]
> 
> HIDDEN inline fastf_t
> 
> This was sent by the SourceForge.net collaborative development platform, the 
> world's largest Open Source development site.
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> BRL-CAD Source Commits mailing list
> brlcad-comm...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/brlcad-commits


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to