{"name":"vectorDiff","title":"vectorDiff","type":"command","url":"https://community.bistudio.com/wiki/vectorDiff","revid":377116,"updated":"2026-01-01T10:12:56Z","groups":["Math - Vectors"],"status":"ok","games":{"arma3":"1.22"},"since":"arma3 1.22","arma3_since":"1.22","description":"Subtracts one 3D vector from another. (vector1 - vector2)\n\n> [!NOTE]\n> **Since Arma 3 v2.14:** Since Arma 3 v2.14 any count of numbers is valid, if one array is larger than the other, the remaining elements are inserted without change.\n> Before Arma 3 v2.14, the first argument had to be vector 3D, or Arma 3 v2.00 2D (Which still returned 3D result, with z coordinate defaulted to 0)","syntaxes":[{"syntax":"vector1 vectorDiff vector2","params":[{"name":"vector1","type":"Array of Numbers","type_expr":"Array<Number>"},{"name":"vector2","type":"Array of Numbers","type_expr":"Array<Number>"}],"returns":{"type":"Array of Numbers","type_expr":"Array<Number>"},"form":"binary","left":{"text":"vector1"},"right":{"text":"vector2"}}],"examples":[{"code":["hint str (velocity car vectorDiff velocity bike);"]}],"see_also":["vectorAdd","vectorCrossProduct","vectorDotProduct","vectorCos","vectorMagnitude","vectorMagnitudeSqr","vectorMultiply","vectorDistance","vectorDistanceSqr","vectorDir","vectorUp","setVectorDir","setVectorUp","setVectorDirAndUp","vectorNormalized","vectorFromTo"],"notes":[{"user":"ffur2007slx2_5","date":"2014-06-28T09:09:00Z","text":"Arma 3 v1.22 Algorithm:\n\n```sqf\nVector1 = [x1,y1,z1]; Vector2 = [x2,y2,z2];\nResult = [x1 - x2, y1 - y2, z1 - z2];\n```\n\nIt is recommended to use vectorDiff instead of BIS_fnc_vectorDiff."}]}