On 21 Dec 2013, at 02:18, Nathan Hurst <njh@...1927...> wrote:
I prefer to declare variables as I use them, but I can't remember what style the code uses.
Yes, we define variables at the point where we need them, so we know how to initialize them meaningfully. I find it makes for hard to maintain code to define variables up front (especially without meaningful initialization).
<rant, please skip> It is 2013, and it is fine to write C99 (or newer) code. And because Inkscape and 2Geom are C++, one should use that language, i.e. not define all variables at start of scope. One thing that is easily overlooked is that "int i;" has different semantics from "Path p;". In "int i;", i is not initialized at all; in "Path p;", p _is_ initialized with the default Path constructor. This possibly confusing point is another reason not to use the pattern unnecessarily. </rant>
- Johan
Can you check please.
if(Geom::are_near(dot(v1,v2),1.0)){ // P1 is within a straight line
I would use cross here, which is more numerically stable in this case because it has error that is linear rather than quadratic with divergences (I think).
if(Geom::are_near(cross(v1,v2),0.0)){ // P1 is within a straight line
Can you fix the spacing up to match the code - you've go a somewhat arbitrary mix of no space, single space and double space around operators.
Other than that, it looks fine.
njh
Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clk... _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel