Cheat Engine
The Official Site of Cheat Engine

Author Message
ghmarko
Cheater
Reputation: 0

Joined: 31 Jan 2020
Posts: 28
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
ParkourPenguin
I post too much
Reputation: 76

Joined: 06 Jul 2014
Posts: 2570

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.
ghmarko
Cheater
Reputation: 0

Joined: 31 Jan 2020
Posts: 28
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?
ParkourPenguin
I post too much
Reputation: 76

Joined: 06 Jul 2014
Posts: 2570

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.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 6 Hours Page 1 of 1

 Jump to: Select a forum Cheat Engine----------------Cheat EngineCheat Engine MacOSCheat Engine Lua ScriptingCheat Engine ExtensionsCheat Engine TutorialsGeneral GamehackingAuto Assembler tutorialsPointer tutorialsGame specific tutorialsWebbrowser stuff related tutorialsConsole ModdingLUA Tutorials General Discussions----------------General DiscussionsArtComputer TalkRandom spamArt RequestsArt TutorialsWillekeurige RotzooiGuestsHorse Excrement Cheat Requests----------------Single player cheat request Cheat Engine Downloads----------------TablesTrainersAuto Assemble scripts Coding----------------Cheat Engine SourceCETC Server and ClientsDBVMPlugin developmentGeneral programmingBinariesCrackmesGeneral programming+Game Development2D Graphics3D ModelingGameplay designWeb Development Games----------------Flash GamesGaia OnlineStick Arena Hello Kitty Forums----------------Temp
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