private static float computeDashLength(float dashLength,float xToYRatio,long prevX,long prevY,long currX,long currY,double prevXNorm,double prevYNorm,double currXNorm,double currYNorm){
  float xDiff=currX - prevX;
  float yDiff=currY - prevY;
  float xDiffScaled=xDiff * xToYRatio;
  float angle=(float)Math.atan2(yDiff,xDiffScaled);
  float xRatio=(float)Math.cos(angle);
  float yRatio=(float)Math.sin(angle);
  float length=(float)Math.sqrt(Math.pow(dashLength * xRatio,2) + Math.pow(dashLength * xToYRatio * yRatio,2));
  float h=(float)Math.sqrt(xDiff * xDiff + yDiff * yDiff);
  float numDashes=h / length;
  float xDiffNorm=(float)(currXNorm - prevXNorm);
  float yDiffNorm=(float)(currYNorm - prevYNorm);
  float hNorm=(float)Math.sqrt(xDiffNorm * xDiffNorm + yDiffNorm * yDiffNorm);
  return hNorm / numDashes;
}

private static float computeDashLength ( float dashLength , float xToYRatio , long prevX , long prevY , long currX , long currY , double prevXNorm , double prevYNorm , double currXNorm , double currYNorm ) { float xDiff = currX - prevX ; float yDiff = currY - prevY ; float xDiffScaled = xDiff * xToYRatio ; float angle = ( float ) Math . atan2 ( yDiff , xDiffScaled ) ; float xRatio = ( float ) Math . cos ( angle ) ; float yRatio = ( float ) Math . sin ( angle ) ; float length = ( float ) Math . sqrt ( Math . pow ( dashLength * xRatio , 2 ) + Math . pow ( dashLength * xToYRatio * yRatio , 2 ) ) ; float h = ( float ) Math . sqrt ( xDiff * xDiff + yDiff * yDiff ) ; float numDashes = h / length ; float xDiffNorm = ( float ) ( currXNorm - prevXNorm ) ; float yDiffNorm = ( float ) ( currYNorm - prevYNorm ) ; float hNorm = ( float ) Math . sqrt ( xDiffNorm * xDiffNorm + yDiffNorm * yDiffNorm ) ; return hNorm / numDashes ; }
given the previous and current points , compute the dash length that should be used based on the slope of the line .
