So I am trying to draw an arrowhead (anywhere really) along a Quad2D curve that specifies a curve between two different points. I want the arrowhead to point towards the final point but cant figure out how to do this. I am familiar with using a Java polygon to create the arrowhead and I tried rotating it using an affine transform (after trying to find the angle using the answer to this question here Calculating angle between two points - java).
My geometry is quite weak and any other suggestions in regards to drawing the curve which would make it easier to position the arrowhead would also be appreciated.
QuadCurve2D.Double my_arc = new QuadCurve2D.Double(x1, y1, cx, cy, x2, y2);
QuadCurve2D.Double part1 = new QuadCurve2D.Double();
QuadCurve2D.Double part2 = new QuadCurve2D.Double();
my_arc.subdivide(part1, part2);
Is how I created the arc, the subdivision is used to find the rough center point of the arc as ideally I want to have the arrowhead in the center (but at the end is fine too) EDIT:
double deltaY = ARC1.y2 - ARC.y1;
double deltaX = ARC1.x2 - ARC.x1;
double angle = Math.atan2(deltaY, deltaX);
Line2D l = new Line2D.Double((int)ARC1.x2, (int)ARC1.y2, (int)ARC.x1, (int)ARC.y1);
int px = (int)ARC1.getX2() - 5;
int py = (int)ARC1.getY2();
Polygon pp = new Polygon(new int[] {px, px+5, px+10},new int[] {py, py+15, py}, 3 );
AffineTransform tt = new AffineTransform();
tt.rotate(angle, pp.getBounds2D().getCenterX(), pp.getBounds2D().getCenterY());
g.draw(tt.createTransformedShape(pp));
g.setColor(Color.red);
g.draw(l);
g.setColor(Color.pink);
g.draw(pp);
Using the above code I get this result Image of results Where the red triangle is the rotated one, am I missing something, like i said my geometry is a bit off