Code Monkey home page Code Monkey logo

affine's Introduction

affine

Vectors and points for 2d graphics or geometry. All methods return new objects, so originals are never mutated.

Example

import {V2, P2} from 'affine';
const v = V2(5, 5);
const p = P2(10, 10);
p.offset(v);

API

V2(x, y)

Initialize a new Vector with x / y.

V2#equals(v:V2)

Check if this vector is equal to v.

V2#plus(v:V2)

Add v to this vector.

V2#minus(v:V2)

Subtract v from this vector.

V2#times(s:Number)

Scale this vector by s.

V2#dot(v:V2)

Return the dot product of this vector and v.

V2#magnitude()

Return the magnitude of this vector.

V2#normalize()

Return a vector with the same direction as this one, and unit length. Returns the zero vector if this vector is zero as well.

V2#rotate(s:Number)

Rotate this vector by s radians.


P2(x, y)

Initialize a new Position with x / y.

P2#equals(p:P2)

Check if this position is equal to p.

P2#offset(v:V2)

Displace this position by the vector v.

P2#getOffset(p:P2)

Return the displacement vector between this position and p.

P2#distance(p:P2)

Return the distance between this position and p.

License

MIT

affine's People

Watchers

James Cloos avatar Matt Kaemmerer 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.