You are performing integer division with 1 / 2
, which in Java results in another integer, 0
, causing your divide by zero error.
Specify that 1
as a float
literal, 1.0f
, to force floating-point arithmetic from the start.
float size = 1 / (1.0f / length * (i+1)) * interpolatedTime;