TorqueScript Reference

- Main Page
- Related Pages
- Modules
- Classes

Functions
Vector2 Math
Function Categories

## Functions
String | Vector2Abs (Vector2 v1, Vector2 v2)
String | Vector2Add (Vector2 v1, Vector2 v2)
Float | Vector2AngleBetween (Vector2 v1, Vector2 v2)
Float | Vector2AngleToPoint (Vector2 p1, Vector2 p2)
String | Vector2AreaNormalize (Vector2 v1, Vector2 v2)
Boolean | Vector2Compare (Vector2 p1, Vector2 p2, [Vector2 epsilon=0.0001]?)
String | Vector2Direction (F32 angle, F32 magnitude)
Float | Vector2Distance (Vector2 p1, Vector2 p2)
Float | Vector2Dot (Vector2 v1, Vector2 v2)
String | Vector2Inverse (Vector2 v1)
String | Vector2InverseX (Vector2 v1)
String | Vector2InverseY (Vector2 v1)
Float | Vector2Length (Vector2 v1)
String | Vector2Mult (Vector2 v1, Vector2 v2)
String | Vector2Normalize (Vector2 v1)
String | Vector2Scale (Vector2 v1, scale)
String | Vector2Sub (Vector2 v1, Vector2 v2)

## Detailed Description

## Function Documentation

String Vector2Abs | ( | Vector2 | v1,
|  | Vector2 | v2
| ) |  |

Absolute difference of two 2-vectors

Returns
  abs(v1-v2)

See Engine Function/Method
  Vector2::absolute

String Vector2Add | ( | Vector2 | v1,
|  | Vector2 | v2
| ) |  |

Add two 2-vectors.

Returns
  v1+v2

See Engine Function/Method
  Vector2::operator+

Float Vector2AngleBetween | ( | Vector2 | v1,
|  | Vector2 | v2
| ) |  |

Angle between two 2D vectors.

Returns
  the angle between v1 and v2.

Float Vector2AngleToPoint | ( | Vector2 | p1,
|  | Vector2 | p2
| ) |  |

Angle from one point to another.

Returns
  the angle from p1 to p2.

String Vector2AreaNormalize | ( | Vector2 | v1,
|  | Vector2 | v2
| ) |  |

Normalize Rectangle (two 2D vectors) with relation to each other.

Returns
  Normalize rectangle of v1 and v2.

Boolean Vector2Compare | ( | Vector2 | p1,
|  | Vector2 | p2,
|  | [Vector2 epsilon=0.0001] ? |
| ) |  |

Equality of two 2D Points. Compares points p1 and p2 with optional difference (epsilon).

Returns
  true if equal

String Vector2Direction | ( | F32 | angle,
|  | F32 | magnitude
| ) |  |

vector from angle and magnitude. Calculates a direction from an angle and magnitude.

Parameters

  angle | The angle of the direction.
  magnitude | The magnitude of the direction.

Returns
  No return value.

Float Vector2Distance | ( | Vector2 | p1,
|  | Vector2 | p2
| ) |  |

Distance between two 2D Points.

Returns
  the distance between points p1 and p2

Float Vector2Dot | ( | Vector2 | v1,
|  | Vector2 | v2
| ) |  |

Dot-Product of two 2D vectors.

Returns
  dot-product of v1 and v2.

See Engine Function/Method
  Vector2::dot

String Vector2Inverse | ( | Vector2 | v1 | ) |

Inverse of a 2D vector.

Returns
  the inverse of v1.

See Engine Function/Method
  Vector2::operator-()

String Vector2InverseX | ( | Vector2 | v1 | ) |

Inverse X component of a 2D vector.

Returns
  the inverse of the v1 X component.

String Vector2InverseY | ( | Vector2 | v1 | ) |

Inverse Y component of a 2D vector.

Returns
  the inverse of the v1 Y component.

Float Vector2Length | ( | Vector2 | v1 | ) |

Length of a 2D vector.

Returns
  the length of v1.

See Engine Function/Method
  Vector2::Length

String Vector2Mult | ( | Vector2 | v1,
|  | Vector2 | v2
| ) |  |

Multiply two 2D vectors (Not Dot-Product!)

Returns
  v1 mult v2.

String Vector2Normalize | ( | Vector2 | v1 | ) |

Normalize a 2D vector.

Returns
  Normalized v1.

See Engine Function/Method
  Vector2::Normalize

String Vector2Scale | ( | Vector2 | v1,
|  | scale |
| ) |  |

Scale a 2D vector.

Returns
  v1 scaled by scale.

See Engine Function/Method
  Vector2::operator*

String Vector2Sub | ( | Vector2 | v1,
|  | Vector2 | v2
| ) |  |

Subtract two 2D vectors.

Returns
  v1-v2

See Engine Function/Method
  Vector2::operator-(Vector2)