Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1fdf6a

Browse files
committed
Minor cleanup and optimization of Sketch
1 parent 018c5ef commit b1fdf6a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/path_converters.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,18 +1037,19 @@ class Sketch
10371037
// We want the "cursor" along the sine wave to move at a
10381038
// random rate.
10391039
double d_rand = m_rand.get_double();
1040-
double d_M_PI = 3.14159265358979323846;
10411040
m_p += pow(m_randomness, d_rand * 2.0 - 1.0);
1042-
double r = sin(m_p / (m_length / (d_M_PI * 2.0))) * m_scale;
10431041
double den = m_last_x - *x;
10441042
double num = m_last_y - *y;
10451043
double len = num * num + den * den;
10461044
m_last_x = *x;
10471045
m_last_y = *y;
10481046
if (len != 0) {
1047+
const double d_M_PI = 3.14159265358979323846;
10491048
len = sqrt(len);
1050-
*x += r * num / len;
1051-
*y += r * -den / len;
1049+
double r = sin(m_p * 2.0 * d_M_PI / m_length) * m_scale;
1050+
double roverlen = r / len;
1051+
*x += roverlen * num;
1052+
*y += roverlen * -den;
10521053
}
10531054
} else {
10541055
m_last_x = *x;

0 commit comments

Comments
 (0)