Code Monkey home page Code Monkey logo

gl-vec2-esm's Introduction

gl-vec2-esm

gl-vec2 ported to ES modules, so that you can do this sort of thing...

import * as vec2 from 'gl-vec2-esm';

const normalized = vec2.normalize(...);

...and take advantage of tree-shaking via Rollup and Webpack 2, rather than having to have a separate require statement for each module.


gl-vec2

stable

Part of a fork of @toji's gl-matrix split into smaller pieces: this package contains glMatrix.vec2.

Usage

NPM

vec2 = require('gl-vec2')

Will load all of the module's functionality and expose it on a single object. Note that any of the methods may also be required directly from their files.

For example, the following are equivalent:

var scale = require('gl-vec2').scale
var scale = require('gl-vec2/scale')

API

add(out:vec2, a:vec2, b:vec2)

Adds two vec2's

clone(a:vec2)

Creates a new vec2 initialized with values from an existing vector

copy(out:vec2, a:vec2)

Copy the values from one vec2 to another

create()

Creates a new, empty vec2

cross(out:vec3, a:vec2, b:vec2)

Computes the cross product of two vec2's Note that the cross product must by definition produce a 3D vector

distance(a:vec2, b:vec2)

Calculates the euclidian distance between two vec2's

divide(out:vec2, a:vec2, b:vec2)

Divides two vec2's

dot(a:vec2, b:vec2)

Calculates the dot product of two vec2's

forEach(a:Array, stride:Number, offset:Number, count:Number, fn:Function, [arg]:Object)

Perform some operation over an array of vec2s.

fromValues(x:Number, y:Number)

Creates a new vec2 initialized with the given values

length(a:vec2)

Calculates the length of a vec2

lerp(out:vec2, a:vec2, b:vec2, t:Number)

Performs a linear interpolation between two vec2's

max(out:vec2, a:vec2, b:vec2)

Returns the maximum of two vec2's

min(out:vec2, a:vec2, b:vec2)

Returns the minimum of two vec2's

multiply(out:vec2, a:vec2, b:vec2)

Multiplies two vec2's

negate(out:vec2, a:vec2)

Negates the components of a vec2

normalize(out:vec2, a:vec2)

Normalize a vec2

random(out:vec2, [scale]:Number)

Generates a random vector with the given scale

scale(out:vec2, a:vec2, b:Number)

Scales a vec2 by a scalar number

scaleAndAdd(out:vec2, a:vec2, b:vec2, scale:Number)

Adds two vec2's after scaling the second operand by a scalar value

set(out:vec2, x:Number, y:Number)

Set the components of a vec2 to the given values

squaredDistance(a:vec2, b:vec2)

Calculates the squared euclidian distance between two vec2's

squaredLength(a:vec2)

Calculates the squared length of a vec2

subtract(out:vec2, a:vec2, b:vec2)

Subtracts vector b from vector a

transformMat2(out:vec2, a:vec2, m:mat2)

Transforms the vec2 with a mat2

transformMat2d(out:vec2, a:vec2, m:mat2d)

Transforms the vec2 with a mat2d

transformMat3(out:vec2, a:vec2, m:mat3)

Transforms the vec2 with a mat3 3rd vector component is implicitly '1'

transformMat4(out:vec2, a:vec2, m:mat4)

Transforms the vec2 with a mat4 3rd vector component is implicitly '0' 4th vector component is implicitly '1'

License

zlib. See LICENSE.md for details.

gl-vec2-esm's People

Contributors

mattdesl avatar rich-harris avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.