Can someone help me with a math thing. I'm trying to calculate the travel distance from point A to point b. this is what i have so far: https://editor.p5js.org/Marcel0024/sketches/Np03rgmxO I can't get the **angle ** to work, in this case i want the circle to be drawn the direction of the mouse click.
Calculate angle formula i got here: https://maththebeautiful.com/angle-between-points/
New point formula i got here: Angle between two Vectors 2D
But i can't get them to work together.
So i have (using mouse position as Point B)
function mouseClicked(){
var angle = Math.atan2(mouseY - point1.y, mouseX - point1.x)
const x = point1.x + Math.sin(angle) * travelDistance;
const y = point1.y - Math.cos(angle) * travelDistance;
circle(x, y, 10)
}
But the angle is way off