GetDistanceBetweenPoints3D: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 17: Line 17:
<syntaxhighlight lang="lua">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 ) )</syntaxhighlight>
outputChatBox ( "The distance between vehicle and vehicle2 is ", getDistanceBetweenPoints3D ( vehiclex, vehicley, vehiclez, vehicle2x, vehicle2y, vehicle2z ) )</syntaxhighlight>

Revision as of 02:39, 20 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 )
outputChatBox ( "The distance between vehicle and vehicle2 is ", getDistanceBetweenPoints3D ( vehiclex, vehicley, vehiclez, vehicle2x, vehicle2y, vehicle2z ) )