# Vec2

class `cee.``Vec2`()

  An immutable 2d vector with x, y values.

  Used e.g. for texture coordinates

Constructors

- `constructor`

Properties

- `x`
- `y`

Methods

- `equals`
- `getLength`
- `getLengthSquared`
- `getNegated`
- `getNormalized`
- `add`
- `dot`
- `from`
- `fromArray`
- `negate`
- `scale`
- `sub`

## Constructors

`Vec2.``constructor`(x, y)

  Arguments: | x (`number`) – None y (`number`) – None

  Constructor

  Return type: | Vec2

## Properties

`Vec2.``x`

  Type: | number

  The x coordinate of the vector

`Vec2.``y`

  Type: | number

  The y coordinate of the vector

## Methods

### equals

`Vec2.``equals`(other)

  Arguments: | other (`Vec2Like`) – None

  Returns true if the vectors are equal

  Return type: | boolean

### getLength

`Vec2.``getLength`()

  Returns the length of the vector (sqrt(x^2 + y^2)).

  Return type: | number

### getLengthSquared

`Vec2.``getLengthSquared`()

  Returns the squared length of the vector

  Return type: | number

### getNegated

`Vec2.``getNegated`()

  Returns a negated version of the vector.

  Return type: | Vec2

### getNormalized

`Vec2.``getNormalized`()

  Returns a normalized version of the vector.

  Return type: | Vec2

### static add

`Vec2.``add`(a, b)

  Arguments: | a (`Vec2Like`) – None b (`Vec2Like`) – None

  Returns the result of adding the two vectors

  Return type: | Vec2

### static dot

`Vec2.``dot`(a, b)

  Arguments: | a (`Vec2Like`) – None b (`Vec2Like`) – None

  Returns the dot product of the 2 vectors

  Return type: | number

### static from

`Vec2.``from`(vec)

  Arguments: | vec (`Vec2Like`) – None

  Creates a new Vec2 instance from any object with x and y properties.

  Return type: | Vec2

### static fromArray

`Vec2.``fromArray`(arr)

  Arguments: | arr (`ArrayLike`) – None

  Creates a new Vec2 instance from the first 2 elements of the given array.

  Return type: | Vec2

### static negate

`Vec2.``negate`(vec)

  Arguments: | vec (`Vec2Like`) – None

  Returns the negation of the given vector

  Return type: | Vec2

### static scale

`Vec2.``scale`(vec, factor)

  Arguments: | vec (`Vec2Like`) – None factor (`number`) – None

  Returns the result of scaling the given vector by the given factor

  Return type: | Vec2

### static sub

`Vec2.``sub`(a, b)

  Arguments: | a (`Vec2Like`) – None b (`Vec2Like`) – None

  Returns the result of subtracting vector b from vector a

  Return type: | Vec2

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your multilingual generative AI assistant for documentation. Ask me anything about HOOPS Envision for Web in your own language, or choose a sample question below to start a conversation:

What is HOOPS Envision for Web?
What are the latest release notes for HOOPS Envision for Web?
How do I start evaluating HOOPS Envision for Web?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...