GithubHelp home page GithubHelp logo

honzabrecka / gama Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 3.0 108 KB

A practical 2D math/geometry library for functional JavaScript, based on Ramda.

License: MIT License

JavaScript 100.00%
functional geometry-library javascript math matrix ramda

gama's People

Contributors

crosseye avatar gilbox avatar honzabrecka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gama's Issues

Why are Matrices represented by columns?

Hi, gama is really cool :) I'm not terribly experienced with using matrix-math libraries so please excuse me if the answer to my question is very obvious.

I was wondering, why are matrix arrays laid out by columns? I mean, if they used rows it would be nice to be able to write a matrix like this:

[1, 0, 0,
 0, 1, 0,
 0, 0, 1]

But the way gama works this would be really confusing since the rows would actually represent columns.

btw, invertMatrix would be nice to have...

var invertMatrix = m => {
  var det = m[0]*m[4]*m[8]
            + m[1]*m[5]*m[6]
            + m[2]*m[3]*m[7]
            - m[0]*m[5]*m[7]
            - m[1]*m[3]*m[8]
            - m[2]*m[4]*m[6];

  return [(m[4] * m[8] - m[5] * m[7]) / det,
          (m[2] * m[7] - m[1] * m[8]) / det,
          (m[1] * m[5] - m[2] * m[4]) / det,
          (m[5] * m[6] - m[3] * m[8]) / det,
          (m[0] * m[8] - m[2] * m[6]) / det,
          (m[2] * m[3] - m[0] * m[5]) / det,
          (m[3] * m[7] - m[4] * m[6]) / det,
          (m[1] * m[6] - m[0] * m[7]) / det,
          (m[0] * m[4] - m[1] * m[3]) / det];
};

Re: change matrix represenation

This commit has some bug I haven't figured out yet, but l am also wondering about the gama.Matrix function signature. Should it be changed to this?

gama.Matrix = function(a, b, tx, c, d, ty)

Currently it is this:

gama.Matrix = function(a, b, c, d, tx, ty)

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.