Vectors
Sourcevec2 DOWN
Source
vec2 LEFT
Source
vec2 RIGHT
Source
vec2 UP
Source
vec2 ZERO2
Source
A vector is a geometric object that has a length and direction.
Vectors can be added to other vectors according to vector algebra.
The most common use in warcraft III is as a point in space. For example a unit's position
can be represented as a vector as well as a knockback force acting on it.
vec3 ZERO3
Source
function vec2.add(real x, real y) returns vec2
Source
Add two reals to the coordiantes of this vector
function vec3.add(real x, real y, real z) returns vec3
Source
add 3 realvalues to the coordinates of this Vector
function vec2.angleTo(vec2 v) returns angle
Source
Get this vetor's angle to another one
function vec3.angleTo2d(vec2 v) returns angle
Source
Get the angle to a 2d vector
function vec3.angleTo2d(vec3 v) returns angle
Source
function vec2.assertEquals(vec2 expected)
Source
function vec3.assertEquals(vec3 expected)
Source
function vec3.cross(vec3 v) returns vec3
Source
Get the cross-product
function angle.direction() returns vec2
Source
returns a vector of length 1 pointing into the direction of this angle
function angle.direction(real dist) returns vec2
Source
returns a vector of length 'dist' pointing into the direction of this angle
function vec2.distanceTo(vec2 v) returns real
Source
Get distance to another vector
function vec3.distanceTo(vec3 v) returns real
Source
Get the distance to another Vector
function vec3.distanceTo2d(vec3 v) returns real
Source
Get the distance to another Vector
function vec3.distanceTo2d(vec2 v) returns real
Source
Get the distance to another Vector
function vec3.distanceTo2dSq(vec2 v) returns real
Source
Get the squared distance to another Vector
function vec2.distanceToSegmentSq(vec2 v1, vec2 v2) returns real
Source
Get squared distance to a line segment
function vec2.distanceToSq(vec2 v) returns real
Source
Get squared distance to another vector
function vec3.distanceToSq(vec3 v) returns real
Source
Get the squared distance to another Vector
function vec2.dot(vec2 v) returns real
Source
Get the dot-product
function vec3.dot(vec3 v) returns real
Source
Get the dot-product
function vec2.getAngle() returns angle
Source
returns the angle of this vector
function vec2.getTerrainZ() returns real
Source
function vec3.getTerrainZ() returns real
Source
function vec2.inRange(vec2 v2, real radius) returns boolean
Source
Is this vector inside the given circle
function vec3.inRange(vec3 v2, real radius) returns boolean
Source
Is this vector inside the given circle
function vec2.isInPolygon(vararg vec2 args) returns boolean
Source
Checks whether the point is in a polygon defined by a sequence of connected points.
function vec3.isInPolygon2d(vararg vec3 args) returns boolean
Source
Checks whether the point is in a 2d polygon defined by a sequence of connected points.
Works as for vec2.isInPolygon, Z-coords are discarded.
function vec2.isInTriangle(vec2 p1, vec2 p2, vec2 p3) returns boolean
Source
Checks whether the point is in a triangle defined by 3 points.
function vec3.isInTriangle2d(vec3 p1, vec3 p2, vec3 p3) returns boolean
Source
Checks whether the point is in a 2D triangle defined by 3 points.
Works as for vec2.isInTriangle, Z-coords are discarded.
function vec2.length() returns real
Source
Get the length of this vector
function vec3.length() returns real
Source
Get the length of this Vector
function vec2.lengthSq() returns real
Source
Get the squared length of this vector
function vec3.lengthSquared() returns real
Source
Get the squared length of this Vector
function vec2.moveTowards(vec2 target, real dist) returns vec2
Source
move a vector towards a given other vector, if the current vector
is equal to the target vector, then the vector will move to the right.
(this emulated the behavior of using polarOffset for this task)
function vec3.moveTowards(vec3 target, real dist) returns vec3
Source
move a vector towards a given other vector, if the current vector
is equal to the target vector, then the vector will move to the right.
(this emulated the behavior of using polarOffset for this task)
function vec2.norm() returns vec2
Source
Normalize this vector
function vec3.norm() returns vec3
Source
Normalize this Vector
function vec2.normalizedPointerTo(vec2 target) returns vec2
Source
returns a vector of length 1 which points into the direction of target,
when this vector and target are equal, then the pointer will point to the right
function vec3.normalizedPointerTo(vec3 target) returns vec3
Source
returns a vector of length 1 which points into the direction of target,
when this vector and target are equal, then the pointer will point to the right
function vec3.offset2d(angle ang, real dist) returns vec3
Source
Offset this vector in 2d space
function vec2.op_divReal(real factor) returns vec2
Source
* Operator
function vec2.op_minus(vec2 v) returns vec2
Source
- Operator
function vec3.op_minus(vec3 v) returns vec3
Source
- Operator
function vec3.op_minus(vec2 v) returns vec3
Source
- Operator
function vec2.op_mult(real factor) returns vec2
Source
* Operator
function real.op_mult(vec2 vec) returns vec2
Source
* Operator
function vec2.op_mult(vec2 v) returns vec2
Source
dot product Operator
function vec3.op_mult(real factor) returns vec3
Source
* Operator
function real.op_mult(vec3 v) returns vec3
Source
dot Operator
function vec2.op_plus(vec2 v) returns vec2
Source
+ Operator vec2
function vec2.op_plus(vec3 v) returns vec2
Source
+ Operator vec3
function vec3.op_plus(vec3 v) returns vec3
Source
+ Operator
function vec3.op_plus(vec2 v) returns vec3
Source
+ Operator
function vec2.polarOffset(angle ang, real dist) returns vec2
Source
Get a polar offset from this vector
function vec3.polarProject(real distance, angle angleGround, angle angleAir) returns vec3
Source
Get a polarprojection of this Vector
function vec3.project(vec3 direction) returns vec3
Source
Project this vector onto the given directional vector
function vec2.rotate(angle angl) returns vec2
Source
Rotate this vector
function vec3.rotate(vec3 axis, real radians) returns vec3
Source
Rotate this vector around an axis
function vec3.rotate(vec3 axis, angle ang) returns vec3
Source
Rotate this vector around an axis
function vec2.setLength(real length) returns vec2
Source
Set the length of this vector
function vec3.setLength(real length) returns vec3
Source
Sets the length of the given Vector
function vec3.setLengthSq(real lengthSq) returns vec3
Source
Sets the length of the given Vector
function vec2.toString() returns string
Source
Get a String-representation of this Vector (for debugging)
function vec3.toString() returns string
Source
Get a String-represantation of the vector (for debugging)
function angle.toVec(real len) returns vec2
Source
returns a vector of the given length pointing into the direction of this angle
function vec3.toVec2() returns vec2
Source
Convert a vec3 to a vec2 (z-coordinate gets removed)
function vec2.toVec3() returns vec3
Source
Convert this vector to a 3d vector with z = 0.
function vec2(real x, real y) returns vec2
Source
2d Vector tuple
function vec3(real x, real y, real z) returns vec3
Source
3d Vector tuple
function vec2.withRadiusRect(real nominalRadius) returns rect
Source
Create a rect centered at `this` with side length 2 * `nominalRadius`.
function vec2.withTerrainZ() returns vec3
Source
function vec2.withTerrainZ(real zoffset) returns vec3
Source
function vec2.withZ(real z) returns vec3
Source
Get a 3d Vector with the original xy and the given z coordinate