I'm trying to draw and rotate an arrow sprite based on a point, around a static circle body without disturbing its starting point of the drawing. The arrow should be pointing in the same direction with the user's point of contact, the static body center vector.
Let me explain with an example.

Here is how I calculate the drawing point of the arrow:
fun powerIndicatorDownPointCalculator(playerPosition: Vector2,touchPosition: Vector2,distanceBetweenTouchPointAndPlayer:Float):Vector2{
// player position is static body center,touch position is touch point.
val playerPositionHolder = playerPosition.cpy()
val abVector = playerPosition.sub(touchPosition);
val normalizedAbVector = Vector2(abVector.x/distanceBetweenFingerAndPlayer,abVector.y/distanceBetweenFingerAndPlayer)
Gdx.app.log("normalized ab vector",normalizedAbVector.toString())
var pointToAddX = 90*normalizedAbVector.x
var pointToAddY = 90*normalizedAbVector.y
var newPointX = playerPositionHolder.x + pointToAddX
var newPointY = playerPositionHolder.y + pointToAddY
Gdx.app.log("NEW POINT", Vector2(newPointX,newPointY).toString())
return Vector2(newPointX,newPointY)
}
Here is a simple gif showing it:
https://i.ibb.co/TvHBMh9/MNML-November19-041320-AM.gif
Here's how I calculate the point C to use later in rotation (?)
fun calculateAimingPoint(playerPosition: Vector2,touchPosition: Vector2):Vector2{
//playerPosition is staticbody center
val abVector = playerPosition.sub(touchPosition);
val secondPos = blackBody.position.cpy()
val cPointPosition = secondPos.add(abVector)
return cPointPosition
}
That's what I wrote for the rotation, but that's for sure that's wrong, because I'm not working the way I wanted to:
var angle = atan2(aimingPoint.y - blackBody.position.y, aimingPoint.x - blackBody.position.x ) *180/ PI ;
//aiming point is C point, blackBody is static body
if (angle > 90)
{
angle = 450 - angle;
}
else
{
angle = 90 - angle;
}
// powerIndicator.setOrigin(????) // setOrigin is for rotation but i dont now what to write here.
angle = angle*-1
powerIndicator.rotation = angle.toFloat()
What I really want to achieve is this:
https://i.ibb.co/gDM9H3L/MNML-November19-042729-AM-2.gif