Method: Processing::GraphicsContext#curveTangent

Defined in:
lib/processing/graphics_context.rb

#curveTangent(a, b, c, d, t) ⇒ Numeric

Calculates the tangent of a point on a curve.

Parameters:

  • a (Numeric)

    coordinate of first control point

  • b (Numeric)

    coordinate of first point on the curve

  • c (Numeric)

    coordinate of second point on the curve

  • d (Numeric)

    coordinate of second control point

  • t (Numeric)

    value between 0.0 and 1.0

Returns:

  • (Numeric)

    tangent value

See Also:



2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
# File 'lib/processing/graphics_context.rb', line 2933

def curveTangent(a, b, c, d, t)
  s = @curveTightness__
  tt3 = t * t * 3.0
  t2  = t * 2.0
  f1  = ( s - 1.0) / 2.0 * tt3 + ( 1.0 - s)       * t2 + (s - 1.0) / 2.0
  f2  = ( s + 3.0) / 2.0 * tt3 + (-5.0 - s) / 2.0 * t2
  f3  = (-3.0 - s) / 2.0 * tt3 + ( s + 2.0)       * t2 + (1.0 - s) / 2.0
  f4  = ( 1.0 - s) / 2.0 * tt3 + ( s - 1.0) / 2.0 * t2
  a * f1 + b * f2 + c * f3 + d * f4
end