Giter Site home page Giter Site logo

linear-algebra's Introduction

Linear algrebra module
by Marc Lepage


OVERVIEW

The linear algebra module can perform common operations on three dimensional
vectors. It's useful when using LuaGL (OpenGL).


USAGE

-- import module
require "la"

-- create a few vectors (any table with numbers at indexes [1] [2] [3])
u, v = {1,0,0}, {0,1,0}

-- compute u + v
r = la.add(u, v) -- results are new vectors (convenience)
la.add(u, v, r)  -- unless a result vector is specified (better performance)
la.add(u, v, u)  -- which can safely be one of the operands (u += v)

-- compute u - v (so u is again {1,0,0})
la.sub(u, v, u)

-- dot product is projection (result is 0 since u and v are orthogonal)
la.dot(u, v)

-- cross product is right handed (result is {0,0,1})
la.cross(u, v)

-- negate and normalize (result is approx {-0.707,-0.707,0})
la.neg(la.norm({1,1,0}))

-- scalar multiplication (2*u) and division (v/3)
la.mul(u, 2)
la.div(v, 3)


RESOURCES

http://en.wikipedia.org/wiki/Linear_algebra
http://en.wikipedia.org/wiki/Euclidean_vector
http://en.wikipedia.org/wiki/Dot_product
http://en.wikipedia.org/wiki/Cross_product

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.