GetDistanceBetweenPoints3D: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:


==Syntax==
==Syntax==
float [[getDistanceBetweenPoints3D]] ( float x1, float y1, float z1, float x2, float y2, float z2 )
<syntaxhighlight lang="lua">getDistanceBetweenPoints3D ( x1, y1, z1, x2, y2, z2 )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
Line 15: Line 15:


==Example==
==Example==
vehiclex, vehicley, vehiclez = [[getVehiclePosition]] ( vehicle )
<syntaxhighlight lang="lua">vehiclex, vehicley, vehiclez = getVehiclePosition ( vehicle )
vehicle2x, vehicle2y, vehicle2z = [[getVehiclePosition]] ( vehicle2 )
vehicle2x, vehicle2y, vehicle2z = getVehiclePosition ( vehicle2 )
[[serverChat]] ( "The distance between vehicle and vehicle2 is ", [[getDistanceBetweenPoints3D]] ( vehiclex, vehicley, vehiclez, vehicle2x, vehicle2y, vehicle2z ) )
serverChat ( "The distance between vehicle and vehicle2 is ", getDistanceBetweenPoints3D ( vehiclex, vehicley, vehiclez, vehicle2x, vehicle2y, vehicle2z ) )</syntaxhighlight>

Revision as of 03:30, 18 May 2006

Description

This function returns the distance between two 3 dimensional points using the pythagorean theorem.

Syntax

getDistanceBetweenPoints3D ( x1, y1, z1, x2, y2, 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

Example

vehiclex, vehicley, vehiclez = getVehiclePosition ( vehicle )
vehicle2x, vehicle2y, vehicle2z = getVehiclePosition ( vehicle2 )
serverChat ( "The distance between vehicle and vehicle2 is ", getDistanceBetweenPoints3D ( vehiclex, vehicley, vehiclez, vehicle2x, vehicle2y, vehicle2z ) )