Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


2D Distance

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
ghmarko
Cheater
Reputation: 0

Joined: 31 Jan 2020
Posts: 28
Location: 192.168.0.1

PostPosted: Fri Mar 20, 2020 7:40 am    Post subject: 2D Distance Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
ParkourPenguin
I post too much
Reputation: 76

Joined: 06 Jul 2014
Posts: 2570

PostPosted: Fri Mar 20, 2020 9:35 am    Post subject: Reply with quote

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
View user's profile Send private message
ghmarko
Cheater
Reputation: 0

Joined: 31 Jan 2020
Posts: 28
Location: 192.168.0.1

PostPosted: Fri Mar 20, 2020 12:59 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
ParkourPenguin
I post too much
Reputation: 76

Joined: 06 Jul 2014
Posts: 2570

PostPosted: Fri Mar 20, 2020 4:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites