Skip to content

Latest commit

 

History

History
282 lines (159 loc) · 5.39 KB

File metadata and controls

282 lines (159 loc) · 5.39 KB

@immugio/three-math-extensions / Exports / Vec2

Class: Vec2

Vec2 represents a 2D vector. It extends Vector2 from the threejs library.

Hierarchy

  • Vector2

    Vec2

Table of contents

Constructors

Methods

Constructors

constructor

new Vec2(x?, y?): Vec2

Parameters

Name Type
x? number
y? number

Returns

Vec2

Inherited from

Vector2.constructor

Defined in

node_modules/@types/three/src/math/Vector2.d.ts:140

Methods

addX

addX(x): Vec2

Adds x amount to this Vec3 instance and return this

Parameters

Name Type
x number

Returns

Vec2

Defined in

src/Vec2.ts:53


addY

addY(y): Vec2

Adds y amount to this Vec3 instance and return this

Parameters

Name Type
y number

Returns

Vec2

Defined in

src/Vec2.ts:44


in3DSpace

in3DSpace(y?): Vec3

Projects this Vec2 instance to a Vec3 instance in 3D space. Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.

Parameters

Name Type Default value Description
y number 0 The y value of the new Vec3 instance.

Returns

Vec3

A new Vec3 instance.

Defined in

src/Vec2.ts:78


isNear

isNear(v, maxDistance?): boolean

Determines if this Vec2 instance is near the target Vec2. maxDistance is the maximum distance between the two vectors within which they are considered near.

Parameters

Name Type Default value
v Vector2 undefined
maxDistance number undefined

Returns

boolean

Defined in

src/Vec2.ts:86


moveTowards

moveTowards(target, amount): Vec2

Moves this Vec2 instance towards the target Vec2 by the given amount.

Parameters

Name Type Description
target Vector2 The target Vec2.
amount number The distance to move.

Returns

Vec2

This Vec2 instance.

Defined in

src/Vec2.ts:34


parallelTo

parallelTo(other, toleranceRadians?): boolean

check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance

Parameters

Name Type Default value Description
other Vector2 undefined Vector2
toleranceRadians number 0 number angle tolerance in radians

Returns

boolean

Defined in

src/Vec2.ts:107


roundIfCloseToInteger

roundIfCloseToInteger(max?): Vec2

Rounds the x and y values of this Vec2 instance if they are close to an integer value.

Parameters

Name Type Default value Description
max number 0.000000000001 The maximum difference between the value and the nearest integer.

Returns

Vec2

This Vec2 instance.

Defined in

src/Vec2.ts:63


signedAngle

signedAngle(): number

Returns the angle between this vector and positive x-axis, the return value is between 0 and 2PI

Returns

number

Defined in

src/Vec2.ts:97


fromPoint

fromPoint(point): Vec2

Creates a new Vec2 instance from an {x, y} object.

Parameters

Name Type Description
point Point2 The {x, y} instance.

Returns

Vec2

A new Vec2 instance.

Defined in

src/Vec2.ts:16


fromPoints

fromPoints(...points): Vec2[]

Creates a new Vec2[] array from arguments of {x, y} objects. *

Parameters

Name Type Description
...points Point2[] The ...{x, y} instances.

Returns

Vec2[]

Defined in

src/Vec2.ts:24