From 04f101d24f7a9c52d0c7880e0b30e996291f13bb Mon Sep 17 00:00:00 2001 From: Hombre Date: Sat, 16 Oct 2010 00:03:15 +0200 Subject: [PATCH] Little optimization of the NURBS curves algorithm --- rtengine/curves.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rtengine/curves.cc b/rtengine/curves.cc index 6922441d4..baccb69f8 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -120,6 +120,8 @@ void Curve::NURBS_set () { int k = 0; for (int i = 0; i < N-1;) { double length; + double dx; + double dy; // first point (on the curve) if (!i) { @@ -146,7 +148,9 @@ void Curve::NURBS_set () { sc_x[j] = (x[i-1] + x[i]) / 2.; sc_y[j] = (y[i-1] + y[i]) / 2.; } - length += sqrt(pow(sc_x[j] - sc_x[j-1],2) + pow(sc_y[j] - sc_y[j-1],2)); + dx = sc_x[j] - sc_x[j-1]; + dy = sc_y[j] - sc_y[j-1]; + length += sqrt(dx*dx + dy*dy); j++; // Storing the length of all sub-curves and the total length (to have a better distribution