[Snippet] Distance Between Two Points

Code:
:DistanceBetweenTwoPoints
0063: 0@ -= 3@  // (float)
0063: 1@ -= 4@  // (float)
0063: 2@ -= 5@  // (float)    
006B: 0@ *= 0@  // (float)
006B: 1@ *= 1@  // (float)
006B: 2@ *= 2@  // (float)        
005B: 0@ += 1@  // (float)
005B: 0@ += 2@  // (float)    
01FB: 0@ = square_root 0@
ret 1 0@

Usage:

Code:
0AB1: call_scm_func @DistanceBetweenTwoPoints 6 Point_1 5@ 6@ 7@  Point_2 8@ 9@ 10@ RetTo 11@

:sadpepe: For no SF users
 

DavidRO99

Active member
Joined
Nov 5, 2017
Messages
60
Reaction score
8
Very useful thanks for sharing what you used to convert it to C++ citar fals csf
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
What's wrong with

[shcode=cpp]
0509: 17@ = distance_between_XY  0@ 1@    and_XY  2@ 3@
050A: 17@ = distance_between_XYZ 0@ 1@ 2@ and_XYZ 3@ 4@ 5@

[/shcode]
 

DavidRO99

Active member
Joined
Nov 5, 2017
Messages
60
Reaction score
8
springfield said:
What's wrong with

[shcode=cpp]
0509: 17@ = distance_between_XY  0@ 1@    and_XY  2@ 3@
050A: 17@ = distance_between_XYZ 0@ 1@ 2@ and_XYZ 3@ 4@ 5@

[/shcode]
I guess this should show you how the calculations actually work, instead of just being like "hey it works idc". It is also useful for translating to other programming languages.
 
Top