Jump to content

GetDistanceVec

From CMM Wiki
Revision as of 10:12, 11 November 2025 by Ozdeadmeat (talk | contribs) (getDistanceVec – created via PowerShell script (2025-11-11T21:12:33Z))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Return to CMM Command Reference
Environment: Mission Scripting
Function: getDistanceVec
Function Description: Calculates the 2D distance between two vectors, handling both vec2 and vec3 inputs by extracting x and z or y coordinates appropriately, then uses GetDistance2D to compute the distance in meters.
File Location: cmm.positionFunctions.lua
Syntax: CMM.getDistanceVec( table vec1 , table vec2 )
Return Value: number
Parameters: Name Description
vec1A vector table representing a point in 3D space, with fields x and optionally z or y; if z exists, it is treated as the y-coordinate for distance calculation.
vec2A vector table representing a point in 3D space, with fields x and optionally z or y; if z exists, it is treated as the y-coordinate for distance calculation.
Example: CMM.getDistanceVec({x=1, y=2, z=3}, {x=4, y=5, z=6})
Example Description: Computes the distance between two 3D points with coordinates (1,2,3) and (4,5,6), returning the 2D distance using x and z as the respective axes.
Related Functions:
Notes: --TODO Retire this command as CMM.Distance does the same thing