diff -uNr gimp-2.2.17/app/paint/gimpink2.c gimp-2.2.17-gpen-work/app/paint/gimpink2.c
--- gimp-2.2.17/app/paint/gimpink2.c	2007-08-18 22:56:52.000000000 +0900
+++ gimp-2.2.17-gpen-work/app/paint/gimpink2.c	2007-08-19 19:20:31.000000000 +0900
@@ -97,6 +97,8 @@
 static GimpCoords     hist_result  (GimpInk2 *ink, GimpInk2Options *options);
 static GimpCoords     hist_result_velocity  (GimpInk2 *ink, GimpInk2Options *options);
 
+static gdouble PI;
+
 
 static GimpPaintCoreClass *parent_class = NULL;
 
@@ -152,6 +154,9 @@
   paint_core_class->paint          = gimp_ink2_paint;
   paint_core_class->get_paint_area = gimp_ink2_get_paint_area;
   paint_core_class->push_undo      = gimp_ink2_push_undo;
+
+  /* initialize internal variables */
+  PI = 4 * atan(1);
 }
 
 static void
@@ -225,6 +230,7 @@
 
     case GIMP_PAINT_STATE_FINISH:
       gimp_ink2_motion (paint_core, drawable, paint_options, time, TRUE);
+//      g_printf("\n");
       break;
     }
 }
@@ -351,27 +357,12 @@
 
       velocity = 10.0 * sqrt ((dist) / (gdouble) (thistime - lasttime));
 
+//      g_printf("%f, %f, %f\n", paint_core->cur_coords.x, paint_core->cur_coords.y, velocity);
+
       if (!at_last && options->compensation_hist_size > 1) 
         {
           hist_add(ink, &paint_core->cur_coords, velocity);
           average_hist = hist_result(ink, options);
-/*
-          if (options->compensation_rate_temperature > 0) 
-            {
-              gdouble rate;
-              gdouble dist2 = sqrt ( (paint_core->cur_coords.x - average_hist.x) *
-                                     (paint_core->cur_coords.x - average_hist.x) +
-                                     (paint_core->cur_coords.y - average_hist.y) *
-                                     (paint_core->cur_coords.y - average_hist.y));
-              gdouble dist3 = sqrt ( (paint_core->cur_coords.x - ink->last_point.x) *
-                                     (paint_core->cur_coords.x - ink->last_point.x) +
-                                     (paint_core->cur_coords.y - ink->last_point.y) *
-                                     (paint_core->cur_coords.y - ink->last_point.y));
-              rate = 1 / (1 + exp(-dist2 / options->compensation_rate_temperature + 0.5 * options->compensation_rate_temperature));
-              average_hist.x = paint_core->cur_coords.x * rate + average_hist.x * (1 - rate);
-              average_hist.y = paint_core->cur_coords.y * rate + average_hist.y * (1 - rate);
-           }
-*/          
           blob = ink2_pen_ellipse (options,
                                   average_hist.x,
                                   average_hist.y,
@@ -684,7 +675,6 @@
 }
 
 
-#define min(x, y) ((x) < (y))? (x) : (y)
 static GimpCoords
 hist_result(GimpInk2 *ink, GimpInk2Options* options)
 {
@@ -693,61 +683,49 @@
   result.x = result.y = 0.0;
   gdouble scale_sum = 0.0;
   if (ink->hist_count > 0) {
-    gint max_hist_count = min(ink->hist_count , options->compensation_hist_size);
-    gint cur_index = (ink->hist_index + INK2_HISTORY_BUFFER - max_hist_count) % INK2_HISTORY_BUFFER; 
-    for (i = 0; i < max_hist_count; i ++, cur_index ++) {
-      gdouble rate = 0;
-      if (cur_index == INK2_HISTORY_BUFFER)
-        cur_index = 0;
-
-      if (options->compensation_rate_temperature != 0) 
-        rate = 1 / (1 + exp(ink->hist_dist_buffer[cur_index] / options->compensation_rate_temperature - 5));
-      scale_sum *= rate;
-      result.x *= rate;
-      result.y *= rate;
-
-      scale_sum += 1.0;
-      result.x += ink->hist_buffer[cur_index].x;
-      result.y += ink->hist_buffer[cur_index].y;
-    }
-    result.x /= scale_sum;
-    result.y /= scale_sum;
-  }
-  return result;
-}
+    gint max_hist_count = MIN(ink->hist_count , options->compensation_hist_size);
+    gint cur_index = (ink->hist_index + INK2_HISTORY_BUFFER - 1) % INK2_HISTORY_BUFFER; 
 
-static GimpCoords
-hist_result_velocity(GimpInk2 *ink, GimpInk2Options* options)
-{
-  gint i;
-  GimpCoords result;
-  result.x = result.y = 0.0;
-  if (ink->hist_count > 1) {
-    gint max_hist_count = min(ink->hist_count ,options->compensation_hist_size);
-    gint cur_index = (ink->hist_index + INK2_HISTORY_BUFFER - max_hist_count + 1) % INK2_HISTORY_BUFFER;
-    gint prev_index = (cur_index + INK2_HISTORY_BUFFER - 1)% INK2_HISTORY_BUFFER;
-    for (i = 0; i < max_hist_count - 1; i ++) {
-      if (cur_index != 0 || ink->hist_count >= INK2_HISTORY_BUFFER) {
-        GimpCoords* prev = &ink->hist_buffer[prev_index];
-//        g_printf("%d-%d: (%f,%f) - (%f,%f) = (%f, %f) --> (%f, %f)\n", cur_index, prev_index, ink->hist_buffer[cur_index].x, ink->hist_buffer[cur_index].y, prev->x, prev->y, ink->hist_buffer[cur_index].x - prev->x, ink->hist_buffer[cur_index].y - prev->y, result.x, result.y);
-        result.x += ink->hist_buffer[cur_index].x - prev->x;
-        result.y += ink->hist_buffer[cur_index].y - prev->y;
+    gdouble gaussian_weight = 0.0;
+    gdouble gaussian_weight2 = options->compensation_rate_temperature * options->compensation_rate_temperature;
+    gdouble velocity_sum = 0.0;
+    if (gaussian_weight2 != 0.0)
+      gaussian_weight = 1 / (sqrt(2 * PI) * options->compensation_rate_temperature);
+
+    for (i = 0; i < max_hist_count; i ++, cur_index --) 
+      {
+        gdouble rate = 0;
+        if (cur_index == -1)
+          cur_index = INK2_HISTORY_BUFFER - 1;
+  
+        if (gaussian_weight2 != 0) 
+          {
+            /* We use gaussian function with velocity as a window function */
+            velocity_sum += ink->hist_dist_buffer[cur_index];
+            rate = gaussian_weight * exp(-velocity_sum*velocity_sum / (2*gaussian_weight2));
+            /* If i == 0 && rate == 0.0, resulting value becomes zero.
+             * To avoid this, we treat this as a special case.
+             */
+            if (i == 0 && rate == 0.0)
+              rate = 1.0;
+          }
+        else
+          {
+            rate = (i == 0) ? 1.0: 0.0;
+          }
+        scale_sum += rate;
+        result.x += rate * ink->hist_buffer[cur_index].x;
+        result.y += rate * ink->hist_buffer[cur_index].y;
+      }
+
+    if (scale_sum != 0.0)
+      {
+        result.x /= scale_sum;
+        result.y /= scale_sum;
       }
-      cur_index ++, prev_index ++;
-      if (prev_index == INK2_HISTORY_BUFFER)
-        prev_index = 0;
-      if (cur_index == INK2_HISTORY_BUFFER)
-        cur_index = 0;
-//    g_printf("Inc: %f, %f\n", result.x, result.y);
-    }
-//    g_printf("Total: %f, %f\n", result.x, result.y);
-    result.x /= max_hist_count;
-    result.y /= max_hist_count;
   }
   return result;
 }
-#undef min
-
 
 /*********************************/
 /*  Rendering functions          */
diff -uNr gimp-2.2.17/app/paint/gimpink2options.c gimp-2.2.17-gpen-work/app/paint/gimpink2options.c
--- gimp-2.2.17/app/paint/gimpink2options.c	2007-08-18 22:56:52.000000000 +0900
+++ gimp-2.2.17-gpen-work/app/paint/gimpink2options.c	2007-08-19 18:55:29.000000000 +0900
@@ -142,13 +142,13 @@
                                    0);
   GIMP_CONFIG_INSTALL_PROP_INT    (object_class, PROP_COMPENSATION_HIST_SIZE,
 				   "compensation-history-size", NULL,
-				   1, INK2_HISTORY_BUFFER, MIN(15, INK2_HISTORY_BUFFER), 0);
+				   1, INK2_HISTORY_BUFFER, MIN(20, INK2_HISTORY_BUFFER), 0);
   GIMP_CONFIG_INSTALL_PROP_BOOLEAN(object_class, PROP_COMPENSATE_AT_LAST,
 				   "compensate-at-last", NULL,
 				   FALSE, 0);
   GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_COMPENSATION_RATE_TEMPERATURE,
                                    "compensation-rate-temperature", NULL,
-                                   0.0, 100, 2.5,
+                                   0.0, 1000, 25,
                                    0);
  }
 
バイナリー・ファイルgimp-2.2.17/app/tools/.gimpinktool2.c.swpとgimp-2.2.17-gpen-work/app/tools/.gimpinktool2.c.swpは違います
