get angle between two points

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By morningkingdom

Hı there,
well im not sure if it works but i tough about how to make godot detect that what i draw is a circle or not, using the angle between two points.

this is my draw:

i thought if i get the every angle between between closest points, and if any of them are not 90 degree or close to 90 degree, its means that angle is smoot, like this:


and in the end what we have will be a circle, at least that what i thought.

is this doable?
i mean i did try few things with angle_to_point or $node.get_angle_to
but cant reach the points one by one, or add them to an array so that i can reach them from there, but couldn’t do that to. And i couldn’t found any example or tutorial on the net either.

so here i am, is this doable? or are there a diffrent way to make godot detect that what draw is, a circle ?

this is how i draw,

extends Node2D
var touch_position = Vector2()
var current_touch = Vector2()

var point_draw

func _input(event):

	if event is InputEventScreenTouch and event.is_pressed():
		touch_position = event.get_position()

	if event is InputEventScreenTouch and not event.is_pressed():

	if event is InputEventScreenDrag:
		current_touch = event.get_position()

	if event is InputEventScreenDrag and not event.is_pressed(): 
		current_touch = null

func _process(delta):
	if current_touch:
		print (current_touch)
		point_draw = current_touch
		if $draw_line.points.size() > 70:

func _on_line_delete_timer_timeout():

and this are nodes:

i think i made a little progress, but not sure solve it or not :smiley:

i add this code:

func _process(delta):
	if current_touch:
		point_draw = current_touch
		var all_points = $draw_line.points
	for point_angles in range(all_points.size() - 1):
		var angle_result= abs(current_touch.angle_to_point($draw_line.points[point_angles-1]))
		print (rad2deg(angle_result))

right now im getting results as a degree, but not sure its the degree of the one point to another, if it is, i need to make something like
if (point_1_degree - point_2_degree == 3 or 5 its means there is a smoot line. so it can be part of the circle.

but am a noob so not sure the returned value is the value that i seek. i mean its looks close that what i want, but i feel something is not right. :D.

this is output :

morningkingdom | 2021-02-20 17:14