File tree 1 file changed +7
-4
lines changed 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1018,6 +1018,8 @@ class Sketch
1018
1018
m_rand(0 )
1019
1019
{
1020
1020
rewind (0 );
1021
+ const double d_M_PI = 3.14159265358979323846 ;
1022
+ m_p_scale = (2.0 * d_M_PI) / m_length;
1021
1023
}
1022
1024
1023
1025
unsigned vertex (double *x, double *y)
@@ -1037,18 +1039,18 @@ class Sketch
1037
1039
// We want the "cursor" along the sine wave to move at a
1038
1040
// random rate.
1039
1041
double d_rand = m_rand.get_double ();
1040
- double d_M_PI = 3.14159265358979323846 ;
1041
1042
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;
1043
1043
double den = m_last_x - *x;
1044
1044
double num = m_last_y - *y;
1045
1045
double len = num * num + den * den;
1046
1046
m_last_x = *x;
1047
1047
m_last_y = *y;
1048
1048
if (len != 0 ) {
1049
1049
len = sqrt (len);
1050
- *x += r * num / len;
1051
- *y += r * -den / len;
1050
+ double r = sin (m_p * m_p_scale) * m_scale;
1051
+ double roverlen = r / len;
1052
+ *x += roverlen * num;
1053
+ *y -= roverlen * den;
1052
1054
}
1053
1055
} else {
1054
1056
m_last_x = *x;
@@ -1083,6 +1085,7 @@ class Sketch
1083
1085
bool m_has_last;
1084
1086
double m_p;
1085
1087
RandomNumberGenerator m_rand;
1088
+ double m_p_scale;
1086
1089
};
1087
1090
1088
1091
#endif // MPL_PATH_CONVERTERS_H
You can’t perform that action at this time.
0 commit comments