math/Dist

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=Dist |Parent=math |Description= |Realm=Shared |IsClass=No }}")
 
m (update source line, minor phrasing changes)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=Dist
+
|Description={{Deprecated|You should use {{LibraryFunction|math|Distance}} instead}}
|Parent=math
+
 
|Description=
+
Returns the difference between two points in 2D space. Alias of {{LibraryFunction|math|Distance}}.
|Realm=Shared
+
|Realm=Shared and Menu
 
|IsClass=No
 
|IsClass=No
 +
|File=lua/includes/extensions/math.lua
 +
|Line=11
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=x1
 +
|desc=X position of first point
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=y1
 +
|desc=Y position of first point
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=x2
 +
|desc=X position of second point
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=y2
 +
|desc=Y position of second point
 +
}}
 +
{{Ret
 +
|type=number
 +
|desc=Distance between the two points.
 +
}}
 +
{{Example
 +
|Description=Demonstrates the use of this function.
 +
|Code=print( math.Distance( 1, 2, 5, 6 ) ) -- distance bet
 +
|Output=5.6568542494924
 
}}
 
}}

Latest revision as of 16:35, 15 November 2016

 math.Dist( )

Contents

Description

This feature is deprecated.
You should avoid using it as it may be removed in a future version.

You should use math.Distance instead

Returns the difference between two points in 2D space. Alias of math.Distance.

Arguments

number x1

X position of first point

Arguments

number y1

Y position of first point

Arguments

number x2

X position of second point

Arguments

number y2

Y position of second point

Returns

number

Distance between the two points.

Examples

Example

Demonstrates the use of this function.

print( math.Distance( 1, 2, 5, 6 ) ) -- distance bet

Output:

5.6568542494924
Personal tools
Navigation