---
name: "vectorDiff"
type: command
status: ok
groups: ["Math - Vectors"]
arma3_since: "1.22"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/vectorDiff
revid: 377116
updated: 2026-01-01T10:12:56Z
---

# vectorDiff

*Command · Math - Vectors · Arma 3 v1.22*

## Description

Subtracts one 3D vector from another. (vector1 - vector2)

> [!NOTE]
> **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.
>
> 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)

## Syntax

```sqf
vector1 vectorDiff vector2
```

**Parameters:**

- `vector1`: [Array](../topics/Array.md) of [Number](../topics/Number.md)s
- `vector2`: [Array](../topics/Array.md) of [Number](../topics/Number.md)s

**Returns:** [Array](../topics/Array.md) of [Number](../topics/Number.md)s

## Examples

### Example 1

```sqf
hint str (velocity car vectorDiff velocity bike);
```

## See also

[vectorAdd](../commands/vectorAdd.md) · [vectorCrossProduct](../commands/vectorCrossProduct.md) · [vectorDotProduct](../commands/vectorDotProduct.md) · [vectorCos](../commands/vectorCos.md) · [vectorMagnitude](../commands/vectorMagnitude.md) · [vectorMagnitudeSqr](../commands/vectorMagnitudeSqr.md) · [vectorMultiply](../commands/vectorMultiply.md) · [vectorDistance](../commands/vectorDistance.md) · [vectorDistanceSqr](../commands/vectorDistanceSqr.md) · [vectorDir](../commands/vectorDir.md) · [vectorUp](../commands/vectorUp.md) · [setVectorDir](../commands/setVectorDir.md) · [setVectorUp](../commands/setVectorUp.md) · [setVectorDirAndUp](../commands/setVectorDirAndUp.md) · [vectorNormalized](../commands/vectorNormalized.md) · [vectorFromTo](../commands/vectorFromTo.md)

## Community notes

**ffur2007slx2_5** — 2014-06-28

Arma 3 v1.22 Algorithm:

```sqf
Vector1 = [x1,y1,z1]; Vector2 = [x2,y2,z2];
Result = [x1 - x2, y1 - y2, z1 - z2];
```

It is recommended to use [vectorDiff](../commands/vectorDiff.md) instead of [BIS_fnc_vectorDiff](../functions/BIS_fnc_vectorDiff.md).

<sub>Source: [BI Community Wiki — vectorDiff](https://community.bistudio.com/wiki/vectorDiff) (revision 377116).</sub>
