Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

# Unigine::vec2 Struct

Vector of 2 float components.

To use this structure, include the UnigineMathLib.h file.

## vec2(const hvec2 & v)

### Arguments

• const hvec2 & v

## vec2()

Default constructor that produces a zero vector.

## vec2(const vec2 & v)

Initialization by a vector.

### Arguments

• const vec2 & v - The value of the vector.

## vec2(float x, float y)

Initialization by scalars.

### Arguments

• float x - X component of the vector.
• float y - Y component of the vector.

## explicit vec2(float v)

Initialization by a scalar: x=v, y=v.

### Arguments

• float v - The value of the vector.

## explicit vec2(const vec3 & v)

Initialization by a four component vector: x=v.x, y=v.y.

### Arguments

• const vec3 & v - The value of the vector.

## explicit vec2(const vec4 & v)

Initialization by a four component vector: x=v.x, y=v.y.

### Arguments

• const vec4 & v - The value of the vector.

## explicit vec2(const dvec2 & v)

Initialization by a vector of double components.

### Arguments

• const dvec2 & v - The value of the vector.

## explicit vec2(const ivec2 & v)

Initialization by a vector of integer components.

### Arguments

• const ivec2 & v - The value of the vector.

## explicit vec2(const float * v)

Initialization by a pointer to the vector.

### Arguments

• const float * v - Pointer to the vector.

## voidset(float x_, float y_)

Set vector.

### Arguments

• float x_ - X component of the vector.
• float y_ - Y component of the vector.

## voidset(const float * val)

Set vector.

### Arguments

• const float * val - Pointer to the vector.

## voidset(const vec2 & val)

### Arguments

• const vec2 & val

• float val

## voidget(float * val) const

Get vector.

### Arguments

• float * val - Pointer to the vector.

## float *get()

Get a pointer to the vector.

### Return value

Pointer to the vector.

## const float *get() const

Get a constant pointer to the vector.

### Return value

Pointer to the vector.

## vec2 &operator*=(float val)

Scalar multiplication.

### Arguments

• float val - The value of the scalar.

### Return value

The resulting vector.

## vec2 &operator*=(const vec2 & val)

Vector multiplication.

### Arguments

• const vec2 & val - The value of the vector.

### Return value

The resulting vector.

## vec2 &operator+=(const vec2 & val)

### Arguments

• const vec2 & val - The value of the vector.

### Return value

The resulting vector.

## vec2operator-() const

Vector negation.

### Return value

The resulting vector.

## vec2 &operator-=(const vec2 & val)

Vector subtraction.

### Arguments

• const vec2 & val - The value of the vector.

### Return value

The resulting vector.

## vec2 &operator/=(const vec2 & val)

### Arguments

• const vec2 & val

• float val

## vec2 &operator=(const vec2 & val)

### Arguments

• const vec2 & val

## float &operator[](int i)

Array access.

### Arguments

• int i - Array item index.

The array item.

## floatoperator[](int i) const

Constant array access.

### Arguments

• int i - Array item index.

The array item.

## int ZERO

Last update: 2017-07-03