 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Rate Version 2 ;) |
| 0\5 |
|
25% |
[ 1 ] |
| 1\5 |
|
0% |
[ 0 ] |
| 2\5 |
|
0% |
[ 0 ] |
| 3\5 |
|
0% |
[ 0 ] |
| 4\5 |
|
50% |
[ 2 ] |
| 5\5 |
|
25% |
[ 1 ] |
|
| Total Votes : 4 |
|
| Author |
Message |
haha01haha01 Grandmaster Cheater Supreme
Reputation: 0
Joined: 15 Jun 2007 Posts: 1233 Location: http://www.SaviourFagFails.com/
|
Posted: Thu May 08, 2008 7:34 am Post subject: HaAngle2 Released!(2.1 now)Creating Angles Was Never Easier! |
|
|
HaAngle Version 2.0 Released! (check a few replies down for the latest version 2.1)
whats new:
1.Angle can now go beyond 90
2.Due to the moving line's trace being curved and not straight now, the two lines will always be the same size
3.all known bugs in V1 fixed
4.completely changed the algorythm used
5.the mirror button was removed
Source and program attached @ bottom.
So, how does the new algorythm works?
heres the code:
| Code: | Line2.X1 = Text2.Text
Line2.X2 = Text3.Text
Line2.Y1 = Text4.Text
Line2.Y2 = Text5.Text
Line1.X2 = Line2.X1
Line1.Y2 = Line2.Y1
If Line2.Y1 > Line2.Y2 Then
lengthofstat = Sqr((Line2.X1 - Line2.X2) ^ 2 + (Line2.Y1 - Line2.Y2) ^ 2)
Else
lengthofstat = Sqr((Line2.X1 - Line2.X2) ^ 2 + (Line2.Y2 - Line2.Y1) ^ 2)
End If
lengthofx = Line2.X1 - Line2.X2
x = (Line2.X1 - Line2.X2) / lengthofstat
If x ^ 2 = 1 Then
alpha = 0
Else
alpha = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
alpha = alpha * (180 / 3.14159265358979)
End If
If Line2.Y1 > Line2.Y2 Then
ang = alpha + Text1.Text
Else
ang = Text1.Text - alpha
End If
angindeg = ang * (3.14159265358979 / 180)
zl = lengthofstat * (Sin(angindeg))
temp = Sqr((lengthofstat ^ 2) + (zl ^ 2))
Line1.Y1 = Line1.Y2 - zl
zx = lengthofstat * (Cos(angindeg))
If Line2.X2 < Line2.X1 Then
Line1.X1 = Line1.X2 - zx
Else
Line1.X1 = Line1.X2 + zx
End If |
2. there are 2 lines. a moving one and a static one. theres also the x and y axis, but they are not shown in the program and they are only used in this explanation to make it easier to understand:
3. | Code: | Line2.X1 = Text2.Text
Line2.X2 = Text3.Text
Line2.Y1 = Text4.Text
Line2.Y2 = Text5.Text
Line1.X2 = Line2.X1
Line1.Y2 = Line2.Y1 |
just some lines that put line2's x,y the coords the user entered in the boxes.
4.now, first we find out what is line2(the static one)'s length. how do we do it? simple. we sub his x values and his y values, and then we get a triangle with 3 lines: a,b,line2.
a is the x length (x1-x2) and b is the y length (y1-y2)
then, after we got a triangle, we know a and b, and we wanna know line2, we simply use pytagoras sentence:
a^2+b^2=line2^2
line2^2=a^2+b^2
line2=sqrt(a^2+b^2)
but what happens if y2 is bigger then y1? we will get a minus length, and that will fux up the program!
thats why i did this:
| Code: | If Line2.Y1 > Line2.Y2 Then
lengthofstat = Sqr((Line2.X1 - Line2.X2) ^ 2 + (Line2.Y1 - Line2.Y2) ^ 2)
Else
lengthofstat = Sqr((Line2.X1 - Line2.X2) ^ 2 + (Line2.Y2 - Line2.Y1) ^ 2)
End If |
that way if y2 is bigger, the calc is y2-y1, and if y1 is bigger the calc is y1-y2.
5.now that we know line2's length, we need to know its angle to the field (x axis in our case). to make it simpler, look at this image:
x axis is now a part of our triangle.
to find the angle between line2 and the x axis, we need to know x axis's length. this is simple: x axis's length is line2's x1-x2.
| Code: | | lengthofx = Line2.X1 - Line2.X2 |
and how do we get the angle? x axis / line2 = cos of the angle between them. | Code: | | x = (Line2.X1 - Line2.X2) / lengthofstat | so we use arccos (inverse cosine) on the result to get the angle. but what happen if we arccos 1 or -1? it will lead to division by 0 = insta death. thats why i made a compare. if the result (x axis / line2) is 1 or -1 it means that the two lines are the same length, which means the angle between them is 0!
btw, stupid vb dont have arccos function, so i had to find one on my own (Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)) and then also turn the result radians --> degrees... (result * (180 / 3.14159265358979))
at last i got this piece of code working for stage 5:
| Code: | If x ^ 2 = 1 Then
alpha = 0
Else
alpha = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
alpha = alpha * (180 / 3.14159265358979)
End If |
6.in this stage, we want to find line 1's angle with the field (x axis). this may seem easy, just adding the angle we got from the user to the angle we got in the previous stage. well, its not SO easy. if line 2 is something like this:
we need to sub the angle we got at previous stage from the user's one. this is the code for this stage: | Code: | If Line2.Y1 > Line2.Y2 Then
ang = alpha + Text1.Text
Else
ang = Text1.Text - alpha
End If |
7.i took the combined angle and turned it back to radians, because vb only work with radians. | Code: | | angindeg = ang * (3.14159265358979 / 180) |
8. i removed line2 from the image because we dont need it anymore.
how do we do this? we make another triangle.
now, do u understand that z's length is the height that the moving line's head need to be? and x is the width!
now, if we can find z line's length, we can just divide it from the starting point (which is known to us, its the point where the two lines meet.) and get the y of the moving lines head. same goes for x line.
9. how do we get them? trigonometry Ftw. we know the angle between x and y. we know that the moving line (y) and the static line's length is the same, so im using the same var for them. this means that z/y = sin of the angle between x and y.
if
z/y=sin angle
z=y * sin angle.
| Code: | | zl = lengthofstat * (Sin(angindeg)) |
ignore these lines, i just forgot to remove them. | Code: | temp = Sqr((lengthofstat ^ 2) + (zl ^ 2))
Line1.Y1 = Line1.Y2 - zl |
now we need to find x. its the same like z but with cosine. x/y = cos angle
x= y*cos angle.
this tha code: | Code: | | zx = lengthofstat * (Cos(angindeg)) |
10. now we know the x,y offsets, and we need to place them. if line2.x2 > line2.x1 it means we are in "mirror" mode, the left\right was replaced by the user, and we need to add instead divide, etc. this is the last part of the code: | Code: | If Line2.X2 < Line2.X1 Then
Line1.X1 = Line1.X2 - zx
Else
Line1.X1 = Line1.X2 + zx
End If |
have fun, and remember, if u didnt unerstand the explanation above, u should listen more in geometry class =D
Last edited by haha01haha01 on Fri May 09, 2008 10:20 am; edited 2 times in total |
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Fri May 09, 2008 1:51 am Post subject: |
|
|
Nice!
(If you're, interested, here's my attempt at it - X)
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Fri May 09, 2008 2:41 am Post subject: |
|
|
Nice. You're better than me at maths that's for sure. But hey, my programs do all of the maths for me .
|
|
| Back to top |
|
 |
haha01haha01 Grandmaster Cheater Supreme
Reputation: 0
Joined: 15 Jun 2007 Posts: 1233 Location: http://www.SaviourFagFails.com/
|
Posted: Fri May 09, 2008 10:03 am Post subject: |
|
|
Updates for V2.1:
1. in this line (stage 5): | Code: | | x = (Line2.X1 - Line2.X2) / lengthofstat |
if line2.x2 is bigger itll fuck up the algo, so i added check. if x2 is bigger the calculation is x2-x1.
2.colored the static line in red.
attached sauce and proggie.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|