|
You last visited: Today at 00:36
Advertisement
Found cordinates on circumference
Discussion on Found cordinates on circumference within the AutoIt forum part of the Coders Den category.
07/05/2014, 14:56
|
#1
|
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
|
Found cordinates on circumference
Hi guys, i've a problem:
i want to find a specific point on a circumference (that there is not on the screen but i can only calculate every point).
My script need to find a picture on the screen, so it get direction line that pass by the center of my circumference and by the center of the picture, so now I have to find the intersection point originated from the line and the circle.
This image will help you:
Until now i made this, but it not find the point well
PHP Code:
$Midx=@DesktopWidth/2 $Midy=@DesktopHeight/2 $x=0 $y=0 $tag =_IMAGESEARCH(@ScriptDir & "\Images\pt.bmp", 1,$x,$y, 18) If $tag=1 Then $dir=point_direction($Midx,$Midy,$x,$y) ClickCircleFromDir($dir,200) EndIf
Func ClickCircleFromDir($dir,$radius) $Midx=@DesktopWidth/2 $Midy=@DesktopHeight/2 Mouseclick ("left",$Midx + ($radius * Cos($dir)),$Midy + ($radius * Sin($dir)),1,0) EndFunc
Func point_direction($x1,$y1,$x2,$y2) Local $dir1,$dir2,$dist $dist=point_distance($x1,$y1,$x2,$y2);get the radius $dir1=ACos(($x2-$x1)/$dist)*(360/3.14);X-derrived angle $dir2=ASin(($y1-$y2)/$dist)*(360/3.14);Y-derrived angle if ($dir2<0) Then return $dir1-(2*$dir2); else return $dir1 EndIf return -1; //Error! EndFunc
Func point_distance($x1, $y1, $x2, $y2) 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
|
|
|
07/05/2014, 15:14
|
#2
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
seems like a basic math problem. though i dont really understand wich information are given. you want to get the x,y of the blue point?
and you have the x,y of the center, the radius and...?
|
|
|
07/05/2014, 16:03
|
#3
|
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
|
the angle of the direction line
|
|
|
07/05/2014, 17:04
|
#4
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
so this is the interesting part:
PHP Code:
Func ClickCircleFromDir($dir,$radius) $Midx=@DesktopWidth/2 $Midy=@DesktopHeight/2 Mouseclick ("left",$Midx + ($radius * Cos($dir)),$Midy + ($radius * Sin($dir)),1,0) EndFunc
math is correct, if angle is 0 at at x axis and is 90° if at top. chek this in ur point_direction func (i didnt check the math here). also check if it has to be ° or radian.
alternative way: create a function f=a+b*x from pic and center position and use the function value with binary search untill you have the point with needed radius.
|
|
|
07/06/2014, 13:12
|
#5
|
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
|
I need to do it fast, so binary search will take much time maybe
|
|
|
07/06/2014, 14:29
|
#6
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
thats how i would have made the angle calculation:
angle =atan(y/x) ;y = ydistance between center and pic...
if x<0 and y >0 then angle = Pi - angle
if x<0 and y< 0 then angle = Pi + angle
if x>0 and y< 0 then angle = 2*Pi - angle
(didnt test it, jsut from mind. if... could be mixed) (result in radian)
|
|
|
07/10/2014, 00:05
|
#7
|
elite*gold: 0
Join Date: Jan 2013
Posts: 426
Received Thanks: 129
|
Use this:
Code:
Func CalcAngle($x1,$y1,$x2,$y2)
Local $radAdd=0
Local $X=($x2-$x1)
Local $Y=($y2-$y1)
Select
Case $Y<0 and $X<0
$radAdd=$pi
Return ATan((-$Y)/(-$X)) + $radAdd
Case $Y<0
$radAdd=2*$pi
Return $radAdd - ATan((-$Y)/$X)
Case $X<0
$radAdd=$pi
Return $radAdd - ATan($Y/(-$X))
Case Else
Return ATan($Y/$X)
EndSelect
EndFunc
Func MovXYbyAngle($x,$y,$angle,$Distance,$IsDeg=1)
If $IsDeg=1 then $Angle/=180/3.14159
Local $aReturn[2]=[$x+(Sin($Angle)),$y+(Cos($Angle))]
Return $aReturn
Endfunc
and with the second function you can even make games.
|
|
|
 |
Similar Threads
|
Poker Tables Cordinates
03/08/2013 - CO2 Private Server - 4 Replies
i would like to add the Poker tables once the player get in its map .. but the problem is i dont know the Poker Cords .. and i searched in INI folder but didnt find any thing useful about it .. so if any1 got all the tables cords and information and willing to share i would be Gratful
Regards
shadowman123
|
cordinates ?
08/25/2011 - Metin2 - 1 Replies
I was asking what are the cordinates for the smiths on 5th floor ( where to kill the demon king at what cordinates for a wep smith , armour ,jewel ... ) Thank you
|
[Help] Random Cordinates
08/06/2010 - EO PServer Hosting - 3 Replies
Hello, I am Nurreo33, a version of Necron33.
I have been lately working in the hush trying to experiment a way of changing the cordinates of an NPC using cq_action code, I am working on a quest in which the player tries to follow an NPC to an end, It's like a Maze in which one fights to reach a last place and gain a reward,I do think It would be fun.
My aim is, when the player talks to the NPC "In charge." and she tells him where to go She would change her cordinates.
My first reference was...
|
anyone for the cordinates for p lvling
04/28/2010 - Conquer Online 2 - 2 Replies
????
|
the xx and yy cordinates?
12/07/2009 - Shaiya - 1 Replies
does any1 where i can find coordintes like xx and yy for the shaiya map of erina.. coordinates for mostly the main towns.. iam using the 10/22/09 trainer and there is teleport so i was wondering where the coordinates for the main towns in erina map are..
|
All times are GMT +1. The time now is 00:37.
|
|