|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ghmarko Cheater Reputation: 0
Joined: 31 Jan 2020 Posts: 29 Location: 192.168.0.1
|
Posted: Fri Mar 20, 2020 7:40 am Post subject: 2D Distance |
|
|
Hello everyone..
How can i calculate 2D distance between 2 points for example
x1 = 562
x2 = 789
y1 = 654
y2 = 698
in assembly
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4300
|
Posted: Fri Mar 20, 2020 9:35 am Post subject: |
|
|
If they're doubles:
Code: | movsd xmm0,[x2]
movsd xmm1,[y2]
subsd xmm0,[x1]
subsd xmm1,[y1]
mulsd xmm0,xmm0
mulsd xmm1,xmm1
addsd xmm0,xmm1
sqrtsd xmm0,xmm0
movsd [distance],xmm0
|
If they're floats, replace *sd with *ss.
If they're integers, use cvtsi2sd.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
ghmarko Cheater Reputation: 0
Joined: 31 Jan 2020 Posts: 29 Location: 192.168.0.1
|
Posted: Fri Mar 20, 2020 12:59 pm Post subject: |
|
|
ParkourPenguin wrote: | If they're doubles:
Code: | movsd xmm0,[x2]
movsd xmm1,[y2]
subsd xmm0,[x1]
subsd xmm1,[y1]
mulsd xmm0,xmm0
mulsd xmm1,xmm1
addsd xmm0,xmm1
sqrtsd xmm0,xmm0
movsd [distance],xmm0
|
If they're floats, replace *sd with *ss.
If they're integers, use cvtsi2sd. |
if they are integers what?
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4300
|
Posted: Fri Mar 20, 2020 4:04 pm Post subject: |
|
|
Code: | pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
cvtsi2sd xmm1,dword ptr[x1]
cvtsi2sd xmm0,dword ptr[x2]
cvtsi2sd xmm2,dword ptr[y1]
subsd xmm0,xmm1
pxor xmm1,xmm1
cvtsi2sd xmm1,dword ptr[y2]
mulsd xmm0,xmm0
subsd xmm1,xmm2
mulsd xmm1,xmm1
addsd xmm0,xmm1
sqrtsd xmm0,xmm0
movsd [distance],xmm0
|
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
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
|
|