test_class.file: confetti/src/test/java/com/github/jinatonic/confetti/confetto/ConfettoTest.java
test_class.identifier: ConfettoTest
test_case.body: @Test
      public void test_computeBound_withAcceleration() {
          // 100 = 0.5 * 0.01 * t * t, t = sqrt(20000) or 141
          long time = Confetto.computeBound(0f, 0f, 0.01f, null, null, -10000, 100);
          assertEquals(141, time);
          time = Confetto.computeBound(0f, 0f, -0.01f, null, null, -100, 10000);
          assertEquals(141, time);
  
          // 100 = 10 + 0.01 * t + 0.5 * 0.01 * t * t, t 3.358
          time = Confetto.computeBound(10f, 0.01f, 0.01f, null, null, -10000, 100);
          assertEquals(133, time);
          time = Confetto.computeBound(-10f, -0.01f, -0.01f, null, null, -100, 10000);
          assertEquals(133, time);
      }
test_case.class_method_signature: ConfettoTest.test_computeBound_withAcceleration()
test_case.full_signature: @Test public void test_computeBound_withAcceleration()
test_case.identifier: test_computeBound_withAcceleration
test_case.invocations: computeBound assertEquals computeBound assertEquals computeBound assertEquals computeBound assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test_computeBound_withAcceleration()
focal_class.declarator: MAX_ALPHA = 255
focal_class.modifier: private static final
focal_class.original_string: private static final int MAX_ALPHA = 255;
focal_class.type: int
focal_class.var_name: MAX_ALPHA
focal_class.declarator: RESET_ANIMATION_INITIAL_DELAY = -1
focal_class.modifier: private static final
focal_class.original_string: private static final long RESET_ANIMATION_INITIAL_DELAY = -1;
focal_class.type: long
focal_class.var_name: RESET_ANIMATION_INITIAL_DELAY
focal_class.declarator: matrix = new Matrix()
focal_class.modifier: private final
focal_class.original_string: private final Matrix matrix = new Matrix();
focal_class.type: Matrix
focal_class.var_name: matrix
focal_class.declarator: workPaint = new Paint(Paint.ANTI_ALIAS_FLAG)
focal_class.modifier: private final
focal_class.original_string: private final Paint workPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
focal_class.type: Paint
focal_class.var_name: workPaint
focal_class.declarator: workPairs = new float[2]
focal_class.modifier: private final
focal_class.original_string: private final float[] workPairs = new float[2];
focal_class.type: float[]
focal_class.var_name: workPairs
focal_class.declarator: bound
focal_class.modifier: private
focal_class.original_string: private Rect bound;
focal_class.type: Rect
focal_class.var_name: bound
focal_class.declarator: initialDelay
focal_class.modifier: private
focal_class.original_string: private long initialDelay;
focal_class.type: long
focal_class.var_name: initialDelay
focal_class.declarator: initialX
focal_class.modifier: private
focal_class.original_string: private float initialX, initialY, initialVelocityX, initialVelocityY,
              accelerationX, accelerationY;
focal_class.type: float
focal_class.var_name: initialX
focal_class.declarator: targetVelocityX
focal_class.modifier: private
focal_class.original_string: private Float targetVelocityX, targetVelocityY;
focal_class.type: Float
focal_class.var_name: targetVelocityX
focal_class.declarator: millisToReachTargetVelocityX
focal_class.modifier: private
focal_class.original_string: private Long millisToReachTargetVelocityX, millisToReachTargetVelocityY;
focal_class.type: Long
focal_class.var_name: millisToReachTargetVelocityX
focal_class.declarator: initialRotation
focal_class.modifier: private
focal_class.original_string: private float initialRotation, initialRotationalVelocity, rotationalAcceleration;
focal_class.type: float
focal_class.var_name: initialRotation
focal_class.declarator: targetRotationalVelocity
focal_class.modifier: private
focal_class.original_string: private Float targetRotationalVelocity;
focal_class.type: Float
focal_class.var_name: targetRotationalVelocity
focal_class.declarator: millisToReachTargetRotationalVelocity
focal_class.modifier: private
focal_class.original_string: private Long millisToReachTargetRotationalVelocity;
focal_class.type: Long
focal_class.var_name: millisToReachTargetRotationalVelocity
focal_class.declarator: ttl
focal_class.modifier: private
focal_class.original_string: private long ttl;
focal_class.type: long
focal_class.var_name: ttl
focal_class.declarator: fadeOutInterpolator
focal_class.modifier: private
focal_class.original_string: private Interpolator fadeOutInterpolator;
focal_class.type: Interpolator
focal_class.var_name: fadeOutInterpolator
focal_class.declarator: millisToReachBound
focal_class.modifier: private
focal_class.original_string: private float millisToReachBound;
focal_class.type: float
focal_class.var_name: millisToReachBound
focal_class.declarator: percentageAnimated
focal_class.modifier: private
focal_class.original_string: private float percentageAnimated;
focal_class.type: float
focal_class.var_name: percentageAnimated
focal_class.declarator: currentX
focal_class.modifier: private
focal_class.original_string: private float currentX, currentY, currentRotation;
focal_class.type: float
focal_class.var_name: currentX
focal_class.declarator: currentVelocityX
focal_class.modifier: protected
focal_class.original_string: protected float currentVelocityX, currentVelocityY, currentRotationalVelocity;
focal_class.type: float
focal_class.var_name: currentVelocityX
focal_class.declarator: alpha
focal_class.modifier: private
focal_class.original_string: private int alpha;
focal_class.type: int
focal_class.var_name: alpha
focal_class.declarator: startedAnimation
focal_class.modifier: private
focal_class.original_string: private boolean startedAnimation, terminated;
focal_class.type: boolean
focal_class.var_name: startedAnimation
focal_class.declarator: touchOverride
focal_class.modifier: private
focal_class.original_string: private boolean touchOverride;
focal_class.type: boolean
focal_class.var_name: touchOverride
focal_class.declarator: velocityTracker
focal_class.modifier: private
focal_class.original_string: private VelocityTracker velocityTracker;
focal_class.type: VelocityTracker
focal_class.var_name: velocityTracker
focal_class.declarator: overrideX
focal_class.modifier: private
focal_class.original_string: private float overrideX, overrideY, overrideVelocityX, overrideVelocityY;
focal_class.type: float
focal_class.var_name: overrideX
focal_class.declarator: overrideDeltaX
focal_class.modifier: private
focal_class.original_string: private float overrideDeltaX, overrideDeltaY;
focal_class.type: float
focal_class.var_name: overrideDeltaX
focal_class.file: confetti/src/main/java/com/github/jinatonic/confetti/confetto/Confetto.java
focal_class.identifier: Confetto
focal_class.class_method_signature: Confetto.prepare(Rect bound)
focal_class.full_signature: public void prepare(Rect bound)
focal_class.identifier: prepare
focal_class.modifiers: public
focal_class.parameters: (Rect bound)
focal_class.return: void
focal_class.signature: void prepare(Rect bound)
focal_class.class_method_signature: Confetto.doesLocationIntercept(float x, float y)
focal_class.full_signature: private boolean doesLocationIntercept(float x, float y)
focal_class.identifier: doesLocationIntercept
focal_class.modifiers: private
focal_class.parameters: (float x, float y)
focal_class.return: boolean
focal_class.signature: boolean doesLocationIntercept(float x, float y)
focal_class.class_method_signature: Confetto.onTouchDown(MotionEvent event)
focal_class.full_signature: public boolean onTouchDown(MotionEvent event)
focal_class.identifier: onTouchDown
focal_class.modifiers: public
focal_class.parameters: (MotionEvent event)
focal_class.return: boolean
focal_class.signature: boolean onTouchDown(MotionEvent event)
focal_class.class_method_signature: Confetto.onTouchMove(MotionEvent event)
focal_class.full_signature: public void onTouchMove(MotionEvent event)
focal_class.identifier: onTouchMove
focal_class.modifiers: public
focal_class.parameters: (MotionEvent event)
focal_class.return: void
focal_class.signature: void onTouchMove(MotionEvent event)
focal_class.class_method_signature: Confetto.onTouchUp(MotionEvent event)
focal_class.full_signature: public void onTouchUp(MotionEvent event)
focal_class.identifier: onTouchUp
focal_class.modifiers: public
focal_class.parameters: (MotionEvent event)
focal_class.return: void
focal_class.signature: void onTouchUp(MotionEvent event)
focal_class.class_method_signature: Confetto.getWidth()
focal_class.full_signature: public abstract int getWidth()
focal_class.identifier: getWidth
focal_class.modifiers: public abstract
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getWidth()
focal_class.class_method_signature: Confetto.getHeight()
focal_class.full_signature: public abstract int getHeight()
focal_class.identifier: getHeight
focal_class.modifiers: public abstract
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getHeight()
focal_class.class_method_signature: Confetto.computeMillisToReachTarget(Float targetVelocity, float initialVelocity,
              float acceleration)
focal_class.full_signature: protected static Long computeMillisToReachTarget(Float targetVelocity, float initialVelocity,
              float acceleration)
focal_class.identifier: computeMillisToReachTarget
focal_class.modifiers: protected static
focal_class.parameters: (Float targetVelocity, float initialVelocity,
              float acceleration)
focal_class.return: Long
focal_class.signature: Long computeMillisToReachTarget(Float targetVelocity, float initialVelocity,
              float acceleration)
focal_class.class_method_signature: Confetto.computeBound(float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)
focal_class.full_signature: protected static long computeBound(float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)
focal_class.identifier: computeBound
focal_class.modifiers: protected static
focal_class.parameters: (float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)
focal_class.return: long
focal_class.signature: long computeBound(float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)
focal_class.class_method_signature: Confetto.reset()
focal_class.full_signature: public void reset()
focal_class.identifier: reset
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void reset()
focal_class.class_method_signature: Confetto.configurePaint(Paint paint)
focal_class.full_signature: protected void configurePaint(Paint paint)
focal_class.identifier: configurePaint
focal_class.modifiers: protected
focal_class.parameters: (Paint paint)
focal_class.return: void
focal_class.signature: void configurePaint(Paint paint)
focal_class.class_method_signature: Confetto.applyUpdate(long passedTime)
focal_class.full_signature: public boolean applyUpdate(long passedTime)
focal_class.identifier: applyUpdate
focal_class.modifiers: public
focal_class.parameters: (long passedTime)
focal_class.return: boolean
focal_class.signature: boolean applyUpdate(long passedTime)
focal_class.class_method_signature: Confetto.computeDistance(float[] pair, long t, float xi, float vi, float ai, Long targetTime,
                                   Float vTarget)
focal_class.full_signature: private void computeDistance(float[] pair, long t, float xi, float vi, float ai, Long targetTime,
                                   Float vTarget)
focal_class.identifier: computeDistance
focal_class.modifiers: private
focal_class.parameters: (float[] pair, long t, float xi, float vi, float ai, Long targetTime,
                                   Float vTarget)
focal_class.return: void
focal_class.signature: void computeDistance(float[] pair, long t, float xi, float vi, float ai, Long targetTime,
                                   Float vTarget)
focal_class.class_method_signature: Confetto.draw(Canvas canvas)
focal_class.full_signature: public void draw(Canvas canvas)
focal_class.identifier: draw
focal_class.modifiers: public
focal_class.parameters: (Canvas canvas)
focal_class.return: void
focal_class.signature: void draw(Canvas canvas)
focal_class.class_method_signature: Confetto.draw(Canvas canvas, float x, float y, float rotation, float percentageAnimated)
focal_class.full_signature: private void draw(Canvas canvas, float x, float y, float rotation, float percentageAnimated)
focal_class.identifier: draw
focal_class.modifiers: private
focal_class.parameters: (Canvas canvas, float x, float y, float rotation, float percentageAnimated)
focal_class.return: void
focal_class.signature: void draw(Canvas canvas, float x, float y, float rotation, float percentageAnimated)
focal_class.class_method_signature: Confetto.drawInternal(Canvas canvas, Matrix matrix, Paint paint, float x,
              float y, float rotation, float percentAnimated)
focal_class.full_signature: protected abstract void drawInternal(Canvas canvas, Matrix matrix, Paint paint, float x,
              float y, float rotation, float percentAnimated)
focal_class.identifier: drawInternal
focal_class.modifiers: protected abstract
focal_class.parameters: (Canvas canvas, Matrix matrix, Paint paint, float x,
              float y, float rotation, float percentAnimated)
focal_class.return: void
focal_class.signature: void drawInternal(Canvas canvas, Matrix matrix, Paint paint, float x,
              float y, float rotation, float percentAnimated)
focal_class.class_method_signature: Confetto.setInitialDelay(long val)
focal_class.full_signature: public void setInitialDelay(long val)
focal_class.identifier: setInitialDelay
focal_class.modifiers: public
focal_class.parameters: (long val)
focal_class.return: void
focal_class.signature: void setInitialDelay(long val)
focal_class.class_method_signature: Confetto.setInitialX(float val)
focal_class.full_signature: public void setInitialX(float val)
focal_class.identifier: setInitialX
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setInitialX(float val)
focal_class.class_method_signature: Confetto.setInitialY(float val)
focal_class.full_signature: public void setInitialY(float val)
focal_class.identifier: setInitialY
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setInitialY(float val)
focal_class.class_method_signature: Confetto.setInitialVelocityX(float val)
focal_class.full_signature: public void setInitialVelocityX(float val)
focal_class.identifier: setInitialVelocityX
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setInitialVelocityX(float val)
focal_class.class_method_signature: Confetto.setInitialVelocityY(float val)
focal_class.full_signature: public void setInitialVelocityY(float val)
focal_class.identifier: setInitialVelocityY
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setInitialVelocityY(float val)
focal_class.class_method_signature: Confetto.setAccelerationX(float val)
focal_class.full_signature: public void setAccelerationX(float val)
focal_class.identifier: setAccelerationX
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setAccelerationX(float val)
focal_class.class_method_signature: Confetto.setAccelerationY(float val)
focal_class.full_signature: public void setAccelerationY(float val)
focal_class.identifier: setAccelerationY
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setAccelerationY(float val)
focal_class.class_method_signature: Confetto.setTargetVelocityX(Float val)
focal_class.full_signature: public void setTargetVelocityX(Float val)
focal_class.identifier: setTargetVelocityX
focal_class.modifiers: public
focal_class.parameters: (Float val)
focal_class.return: void
focal_class.signature: void setTargetVelocityX(Float val)
focal_class.class_method_signature: Confetto.setTargetVelocityY(Float val)
focal_class.full_signature: public void setTargetVelocityY(Float val)
focal_class.identifier: setTargetVelocityY
focal_class.modifiers: public
focal_class.parameters: (Float val)
focal_class.return: void
focal_class.signature: void setTargetVelocityY(Float val)
focal_class.class_method_signature: Confetto.setInitialRotation(float val)
focal_class.full_signature: public void setInitialRotation(float val)
focal_class.identifier: setInitialRotation
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setInitialRotation(float val)
focal_class.class_method_signature: Confetto.setInitialRotationalVelocity(float val)
focal_class.full_signature: public void setInitialRotationalVelocity(float val)
focal_class.identifier: setInitialRotationalVelocity
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setInitialRotationalVelocity(float val)
focal_class.class_method_signature: Confetto.setRotationalAcceleration(float val)
focal_class.full_signature: public void setRotationalAcceleration(float val)
focal_class.identifier: setRotationalAcceleration
focal_class.modifiers: public
focal_class.parameters: (float val)
focal_class.return: void
focal_class.signature: void setRotationalAcceleration(float val)
focal_class.class_method_signature: Confetto.setTargetRotationalVelocity(Float val)
focal_class.full_signature: public void setTargetRotationalVelocity(Float val)
focal_class.identifier: setTargetRotationalVelocity
focal_class.modifiers: public
focal_class.parameters: (Float val)
focal_class.return: void
focal_class.signature: void setTargetRotationalVelocity(Float val)
focal_class.class_method_signature: Confetto.setTTL(long val)
focal_class.full_signature: public void setTTL(long val)
focal_class.identifier: setTTL
focal_class.modifiers: public
focal_class.parameters: (long val)
focal_class.return: void
focal_class.signature: void setTTL(long val)
focal_class.class_method_signature: Confetto.setFadeOut(Interpolator fadeOutInterpolator)
focal_class.full_signature: public void setFadeOut(Interpolator fadeOutInterpolator)
focal_class.identifier: setFadeOut
focal_class.modifiers: public
focal_class.parameters: (Interpolator fadeOutInterpolator)
focal_class.return: void
focal_class.signature: void setFadeOut(Interpolator fadeOutInterpolator)
focal_method.body: protected static long computeBound(float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound) {
          if (acceleration != 0) {
              // non-zero acceleration
              final int bound = acceleration > 0 ? maxBound : minBound;
  
              if (targetTime == null || targetTime < 0) {
                  // https://www.wolframalpha.com/input/
                  // ?i=solve+for+t+in+(d+%3D+x+%2B+v+*+t+%2B+0.5+*+a+*+t+*+t)
  
                  final double tmp = Math.sqrt(
                          2 * acceleration * bound - 2 * acceleration * initialPos
                                  + velocity * velocity);
  
                  final double firstTime = (-tmp - velocity) / acceleration;
                  if (firstTime > 0) {
                      return (long) firstTime;
                  }
  
                  final double secondTime = (tmp - velocity) / acceleration;
                  if (secondTime > 0) {
                      return (long) secondTime;
                  }
  
                  return Long.MAX_VALUE;
              } else {
                  // d = x + v * tm + 0.5 * a * tm * tm + tv * (t - tm)
                  // d - x - v * tm - 0.5 * a * tm * tm = tv * t - tv * tm
                  // d - x - v * tm - 0.5 * a * tm * tm + tv * tm = tv * t
                  // t = (d - x - v * tm - 0.5 * a * tm * tm + tv * tm) / tv
  
                  final double time =
                          (bound - initialPos - velocity * targetTime -
                                  0.5 * acceleration * targetTime * targetTime +
                                  targetVelocity * targetTime) /
                          targetVelocity;
  
                  return time > 0 ? (long) time : Long.MAX_VALUE;
              }
          } else {
              float actualVelocity = targetTime == null ? velocity : targetVelocity;
              final int bound = actualVelocity > 0 ? maxBound : minBound;
              if (actualVelocity != 0) {
                  final double time = (bound - initialPos) / actualVelocity;
                  return time > 0 ? (long) time : Long.MAX_VALUE;
              } else {
                  return Long.MAX_VALUE;
              }
          }
      }
focal_method.class_method_signature: Confetto.computeBound(float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)
focal_method.full_signature: protected static long computeBound(float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)
focal_method.identifier: computeBound
focal_method.invocations: sqrt
focal_method.modifiers: protected static
focal_method.parameters: (float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)
focal_method.return: long
focal_method.signature: long computeBound(float initialPos, float velocity, float acceleration,
              Long targetTime, Float targetVelocity, int minBound, int maxBound)