getDistanceBetweenPoints3D
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function returns the distance between two 3 dimensional points using the pythagorean theorem.
Note
This function is equivalent to the Vector3 class getLength method when used with a vector that holds the direction and distance between two points. In other words, it produces exactly the same result as substracting the points' coordinates and getting the length of the result vector.
Syntax
float getDistanceBetweenPoints3D ( float x1, float y1, float z1, float x2, float y2, float z2 )Required Arguments
- x1: The X position of the first point
- y1: The Y position of the first point
- z1: The Z position of the first point
- x2: The X position of the second point
- y2: The Y position of the second point
- z2: The Z position of the second point
Returns
- float: value
Returns a float containing the distance between the two points as a float . Returns false if an argument passed was invalid.
Code Examples
shared
-- create the vehicles which we're going to measure distance between ofvehicle1 = createVehicle(445, -2629.79248, 1370.82996, 7.10079)vehicle2 = createVehicle(560, -2629.71899, 1350.18188, 7.10897)
-- get position of both created vehiclesvehicle1x, vehicle1y, vehicle1z = getElementPosition(vehicle1)vehicle2x, vehicle2y, vehicle2z = getElementPosition(vehicle2)
-- measure the distanceoutputChatBox("The distance between vehicle1 and vehicle2 is " ..tostring(getDistanceBetweenPoints3D(vehicle1x, vehicle1y, vehicle1z, vehicle2x, vehicle2y, vehicle2z)))See Also
Utility Functions
- addDebugHook
- bitAnd
- bitArShift
- bitExtract
- bitLRotate
- bitLShift
- bitNot
- bitOr
- bitReplace
- bitRRotate
- bitRShift
- bitTest
- bitXor
- createTrayNotification
- debugSleep
- decodeString
- deref
- downloadFile
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getFPSLimit
- getKeyboardLayout
- getLocalization
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getProcessMemoryStats
- getRealTime
- getServerIp
- getTickCount
- getTimerDetails
- getTimers
- gettok
- getUserdataType
- getVersion
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTimer
- isTimerPaused
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- ref
- removeDebugHook
- resetTimer
- setClipboard
- setDevelopmentMode
- setFPSLimit
- setTimer
- setTimerPaused
- setTransferBoxVisible
- setWindowFlashing
- sha256
- showCol
- showSound
- split
- teaDecode
- teaEncode
- tocolor
- toJSON
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub