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:
[Only registered and activated users can see links. Click Here To Register...]
Until now i made this, but it not find the point well :(
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:
[Only registered and activated users can see links. Click Here To Register...]
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