GetDistanceBetweenPoints2D: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (Changed template, added sections) |
||
Line 1: | Line 1: | ||
{{Server function}} | {{Server client function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function returns the distance between two 2 dimensional points using the pythagorean theorem. | This function returns the distance between two 2 dimensional points using the pythagorean theorem. | ||
==Syntax== | ==Syntax== | ||
<section name="Server and client" class="both" show="true"> | |||
<syntaxhighlight lang="lua">float getDistanceBetweenPoints2D ( float x1, float y1, float x2, float y2 )</syntaxhighlight> | <syntaxhighlight lang="lua">float getDistanceBetweenPoints2D ( float x1, float y1, float x2, float y2 )</syntaxhighlight> | ||
Line 14: | Line 15: | ||
===Returns=== | ===Returns=== | ||
Returns a [[float]] containing the 2D distance between the two points. Returns ''false'' if invalid parameters are passed. | Returns a [[float]] containing the 2D distance between the two points. Returns ''false'' if invalid parameters are passed. | ||
</section> | |||
==Example== | ==Example== | ||
<section name="Server and client" class="both" show="true"> | |||
This example gets the distance between two vehicles, stored in variables ''vehicle1'' and ''vehicle2''. | This example gets the distance between two vehicles, stored in variables ''vehicle1'' and ''vehicle2''. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 22: | Line 25: | ||
outputChatBox ( "The map distance between vehicle1 and vehicle2 is ", getDistanceBetweenPoints2D ( vehicle1x, vehicle1y, vehicle2x, vehicle2y ) ) | outputChatBox ( "The map distance between vehicle1 and vehicle2 is ", getDistanceBetweenPoints2D ( vehicle1x, vehicle1y, vehicle2x, vehicle2y ) ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Utility functions}} | {{Utility functions}} |
Revision as of 15:41, 16 September 2007
This function returns the distance between two 2 dimensional points using the pythagorean theorem.
Syntax
Click to collapse [-]
Server and clientfloat getDistanceBetweenPoints2D ( float x1, float y1, float x2, float y2 )
Required Arguments
- x1: The X position of the first point
- y1: The Y position of the first point
- x2: The X position of the second point
- y2: The Y position of the second point
Returns
Returns a float containing the 2D distance between the two points. Returns false if invalid parameters are passed.
Example
Click to collapse [-]
Server and clientThis example gets the distance between two vehicles, stored in variables vehicle1 and vehicle2.
vehicle1x, vehicle1y, vehicle1z = getElementPosition ( vehicle1 ) vehicle2x, vehicle2y, vehicle2z = getElementPosition ( vehicle2 ) outputChatBox ( "The map distance between vehicle1 and vehicle2 is ", getDistanceBetweenPoints2D ( vehicle1x, vehicle1y, vehicle2x, vehicle2y ) )
See Also
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace