More angle related shenanigans, even with the understanding that the angle increases clockwise, the angle from origin to a point directly on the right should still be 0, right?

I'm assuming, of course, that angle_to_point() is supposed to be used as Origin.angle_to_point(Destination) but is there a reason why the designer intended it to be used as Destination.angle_to_point(Origin)?

source code:

func _ready(): #DEBUG: trying to figure out how angle_to_point works
	var pointA := Vector2(0,0)
	var pointB := Vector2(100,0) #should be to the right of A
	var AtoB := str(pointA.angle_to_point(pointB))
	var BtoA := str(pointB.angle_to_point(pointA))
	print_debug("A to B, expected value: 0, actual: "+AtoB) #actual: 3.141593
	print_debug("B to A, expected value: 3.14..., actual: "+BtoA) #actual: 0

DaveTheCoder Yeah, illustration on the document is actually just opposite to what I think should be the case, guess I'll just have to adjust my intuition for Godot's angles

Looking at the source, angle_to_point is definitely going backwards.
a.angle_to_point(b) is doing a-b to get the vector between them instead of b-a. So the parameter named "to" in the docs should be called "from".
(In the code it's just called p_vector2 like several other functions and there's no code comments to explain the intent of the parameter)

Okay, I tested it, and it's completely wrong. You are correct about this one.

Try this, it makes even less sense:

var point_from = Vector2.ZERO
var point_to = Vector2(100, 100)
var angle_to_point = point_from.angle_to_point(point_to)
print("angle to point (100, 100) = ", rad2deg(angle_to_point))
point_to = Vector2(-100, 100)
angle_to_point = point_from.angle_to_point(point_to)
print("angle to point (-100, 100) = ", rad2deg(angle_to_point))

Maybe I'm not following this discussion, but angle_to_point() is defined as

Returns the angle between the line connecting the two points and the X axis, in radians.

Isn't that exactly what it's doing? The sign of the angle will depend on where the X axis is compared to the two points. I'd assume it's the horizontal line intersecting the first point.

Edit: Oh, I see what you mean. The illustration shows that the X axis is the horizontal line intersecting the second point, which fits the definition, but is a bit counter-intuitive to me at least.

https://github.com/godotengine/godot/issues/16307

cybereality Funny it took them 3 years to notice...

Well, I'm not going to complain too loudly since I couldn't even keep up with the discussion of the problem. 🙂

Well aside from that, the function doesn't even make sense and I never heard of it. LOL.

cybereality Funny it took them 3 years to notice...

In one of those github threads, there was a comment that the function wasn't really useful, since it's just as easy to use the expression (b - a).angle().