# how to choose a point that is closest?

## Recommended Posts

I have this theorem for selection and the nearest point, but I do not understand how to work with her who can give an example or explain?

```Func Pixel_Distance(\$x1, \$y1, \$x2, \$y2);Pythagoras theorem for 2D
Local \$a, \$b, \$c
If \$x2 = \$x1 And \$y2 = \$y1 Then
Return 0
Else
\$a = \$y2 - \$y1
\$b = \$x2 - \$x1
\$c = Sqrt(\$a * \$a + \$b * \$b)
Return \$c
EndIf
EndFunc;==>Pixel_Distance```

how to choose a red points that is closest to the black?

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

##### Share on other sites

You pass the function two sets of X/Y coordinates, and it will return the distance between them.

Your topic title is: "how to choose a point that is closest?"

Closest to what?

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

##### Share on other sites

This function returns the distance in pixels from one point (\$x1,\$y1) to another Point (\$x2,\$y2)

```If the x coords and y coords are equal Then
Return 0 ; Point1 and Point2 have the same coords, distance 0
Else
\$a = \$y2 - \$y1 ; get x distance between Points
\$b = \$x2 - \$x1 ; get y distance between Points
\$c = Sqrt(\$a * \$a + \$b * \$ B) ; do pythagoras to get length
Return \$c ; return length
EndIf```

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

##### Share on other sites

You pass the function two sets of X/Y coordinates, and it will return the distance between them.

Your topic title is: "how to choose a point that is closest?"

Closest to what?

"how to choose a red points that is closest to the black? "

Updated post updated

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

##### Share on other sites

This function returns the distance in pixels from one point (\$x1,\$y1) to another Point (\$x2,\$y2)

```If the x coords and y coords are equal Then
Return 0 ; Point1 and Point2 have the same coords, distance 0
Else
\$a = \$y2 - \$y1 ; get x distance between Points
\$b = \$x2 - \$x1 ; get y distance between Points
\$c = Sqrt(\$a * \$a + \$b * \$ B) ; do pythagoras to get length
Return \$c ; return length
EndIf```

yes i know what is do but i dont understand how to use it

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

##### Share on other sites

You have an image with an black dot and some random red dots.

You want to get the coordiantes of that red dot that is closest to the black dot.

So using a function which gets you the distance from two coords requires that you already know the coords of the points.

To make it complicated you would have to store every points coords in an array and make a loop where you get the distance to every point, store the distance with the coords, and in the end compare all distances to get the closest coords.

A bit complicated

I suggest you do a more "radar" style approach.

Use PixelGetColor to find the black dot.

Then run PixelGetColor in circles around the black with increasing the radius of the "scan" every turn.

If you find your first red pixel, thats the closest one

By the way: What game is that again? I remember that i've played it once ^^

Edited by qsek

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

##### Share on other sites

You have an image with an black dot and some random red dots.

You want to get the coordiantes of that red dot that is closest to the black dot.

So using a function which gets you the distance from two coords requires that you already know the coords of the points.

To make it complicated you would have to store every points coords in an array and make a loop where you get the distance to every point, store the distance with the coords, and in the end compare all distances to get the closest coords.

A bit complicated

I suggest you do a more "radar" style approach.

Use PixelGetColor to find the black dot.

Then run PixelGetColor in circles around the black with increasing the radius of the "scan" every turn.

If you find your first red pixel, thats the closest one

By the way: What game is that again? I remember that i've played it once ^^

```\$coord = PixelSearch( 170, 126, 960, 390, 0xFFFFFF );hero
\$left = \$coord[0]-100
\$top = \$coord[1]-100
\$right = \$coord[0]+100
\$buttom = \$coord[1]+100
\$coord1 = PixelSearch( \$left, \$top, \$right, \$buttom, 0xFEAE2C );monster
If Not @error Then
Send("{SHIFTDOWN}")
MouseClick("primary", \$coord1[0]+30, \$coord1[1]+15, 1)
Send("{SHIFTUP}")
Send("d")
Send("{SHIFTDOWN}")
MouseClick("primary", \$coord1[0]+30, \$coord1[1]+15, 1)
Send("{SHIFTUP}")
Send("d")
EndIf```

and I also use Square bc cant do circle in order to atack if monstar within a radius of 100 pixels to click on it 10 races

but how to make the radar does not come to mind: (

more Square? checkpixel in 1Square if in Square1 no redpixel checkpixel in 2Square if in Square2 no redpixel check..... y?

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

##### Share on other sites

and I also use Square bc cant do circle in order to atack if monstar within a radius of 100 pixels to click on it 10 races

but how to make the radar does not come to mind: (

more Square? checkpixel in 1Square if in Square1 no redpixel checkpixel in 2Square if in Square2 no redpixel check..... y?

lol do you use google translator? i can not really read what you say

Anyway i think this one will be used for making a bot, so good luck

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

##### Share on other sites

lol do you use google translator? i can not really read what you say

Anyway i think this one will be used for making a bot, so good luck

sry(( y i use google)) and y i wanna do bot but im in AutoIt 4 days and dont have big experience in this((

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

##### Share on other sites

You have an image with an black dot and some random red dots.

You want to get the coordiantes of that red dot that is closest to the black dot.

So using a function which gets you the distance from two coords requires that you already know the coords of the points.

To make it complicated you would have to store every points coords in an array and make a loop where you get the distance to every point, store the distance with the coords, and in the end compare all distances to get the closest coords.

A bit complicated

I suggest you do a more "radar" style approach.

Use PixelGetColor to find the black dot.

Then run PixelGetColor in circles around the black with increasing the radius of the "scan" every turn.

If you find your first red pixel, thats the closest one

By the way: What game is that again? I remember that i've played it once ^^

How to find all red points? if i searchpixel it find 1 point but how to find all?

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

## Create an account

Register a new account