0

I want to draw trajectory path based on car steering move. here I have few dummy data InnerRadius, OuterRadius and SteeringWheelangle.

public void drawCurvedArrow(float x1, float y1, float x2, float y2, float curveRadius, int lineWidth,Canvas canvas) {
    Paint paint  = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.STROKE);

    paint.setStrokeWidth(lineWidth);
    paint.setColor(Color.YELLOW);
    final Path path = new Path();
    float midX            = x1 + ((x2 - x1) / 2);
    float midY            = y1 + ((y2 - y1) / 2);
    float xDiff         = midX - x1;
    float yDiff         = midY - y1;
    double angle        = (Math.atan2(yDiff, xDiff) * (180 / Math.PI)) - 90;
    double angleRadians = Math.toRadians(angle);
    float pointX        = (float) (midX + curveRadius * Math.cos(angleRadians));
    float pointY        = (float) (midY + curveRadius * Math.sin(angleRadians));

    path.moveTo(x1, y1);
    path.cubicTo(x1,y1,pointX, pointY, x2, y2);
    canvas.drawPath(path, paint);
}

like this.

enter image description here

Narendra
  • 967
  • 15
  • 29

0 Answers0