diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index a21511acb..b86148c9d 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -1796,10 +1796,23 @@ public abstract class PGraphics extends PImage implements PConstants { } + /** + * Calculate the tangent at a t value (0..1) on a Catmull-Rom curve. + * Code thanks to Dave Bollinger (Bug #715) + */ public float curveTangent(float a, float b, float c, float d, float t) { - System.err.println("curveTangent not yet implemented"); - return 0; + if (!curve_inited) curve_init(); + + float tt3 = t * t * 3; + float t2 = t * 2; + float m[][] = curve_basis; + + // not optimized (and probably need not be) + return (a * (tt3*m[0][0] + t2*m[1][0] + m[2][0]) + + b * (tt3*m[0][1] + t2*m[1][1] + m[2][1]) + + c * (tt3*m[0][2] + t2*m[1][2] + m[2][2]) + + d * (tt3*m[0][3] + t2*m[1][3] + m[2][3]) ); } diff --git a/core/todo.txt b/core/todo.txt index 0435931c3..a647d9c69 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -13,8 +13,13 @@ X perhaps something gets corrected? X had a fix, but decided not to re-implement the loadTIFF stuff too X fix for bezierTangent() problem from dave bollinger X http://dev.processing.org/bugs/show_bug.cgi?id=710 +X implement curveTangent (thanks to davbol) +X http://dev.processing.org/bugs/show_bug.cgi?id=715 -test +_ loadStrings(".") should not list directory contents +_ http://dev.processing.org/bugs/show_bug.cgi?id=716 + +_ remove saveFile() methods? _ ENABLE_DEPTH_SORT causing trouble with MovieMaker _ need to make the flush() api accessible _ http://dev.processing.org/bugs/show_bug.cgi?id=692 @@ -435,9 +440,8 @@ _ rewrite line and stroke code, it's a buggy mess _ lines become 2 pixels thick after a 3D transform _ better handling of single-pixel special case _ flat_line_retribution is a hack, can go away -_ implement curveTangent -_ fix-up the curve_init() and the rest to use matrices -_ and not have ugly names (i.e. just g.curveDetail is good) +_ fix-up the curve_init() and the rest to use matrices +_ and not have ugly names (i.e. just g.curveDetail is good) _ ellipse scaling method isn't great _ http://dev.processing.org/bugs/show_bug.cgi?id=695 _ weird ellipse bug with an alpha line in same image