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():
		$line_delete_timer.start()

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

		
	if event is InputEventScreenDrag and not event.is_pressed():
		yield(get_tree().create_timer(0.25),"timeout")
		current_touch = null


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


func _on_line_delete_timer_timeout():
	$draw_line.clear_points()
	$line_delete_timer.stop()

and this are nodes:

Think of the definition of a circle, then square and increasingly many sided approximations of a circle.

A triangle and then more-sided approximation must have at least four criteria: 1. be (close to a) closed shape 2. have an internal set of angles that == 180 (for 3 vertices), then 360' for more vertices (internal is defined by step 3 3. each dot for dots [2, ..., N] must be on the same side of its previous neighbor. When you have 3 vertices, detect which 'side' the latest vertex, p[n] is on of the line defined by p[n-1] and p[n-2]. (This is done by defining a line perpendicular to p_2 - p_1, then taking the dot product). 4. And lastly that the angles of points in step 3 are approximately the same.

Criteria 3 and 4 can usually be computed if you can compute the angle between p_3 and p_2 - p_1, in this case the angles sign must be the same, and they must be the same magnitude (roughly)

the sides should of course be of equal length, but when you 'drop' points based on the distance from the previous post, that condition is met

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

i add this code:

func _process(delta):
	if current_touch:
		point_draw = current_touch
		$draw_line.add_point(point_draw)
		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 : https://streamable.com/ct0zev

2 years later