Coder Social home page Coder Social logo

graphmath's People

Contributors

codeingboss avatar crertel avatar host32 avatar jeregrine avatar kesipyc avatar matthewphilyaw avatar robertdober avatar sztheory avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphmath's Issues

Cleanup docs.

So, the documentation for the modules is a little hard to navigate.

Also, the description for the library as it appears in Hex is a bit off.

Lastly, thanks to @RobertDober's help, we have a chance to update to a new version of ex_doc and to acknowledge his help as a contributor. :)

Optimization: add type guards to functions?

Apparently adding type guards on numerical functions can let the BEAM optimizer generate better code, Wings3D uses this heavily. If you're interested I can try it out and benchmark how much it actually helps.

Inclusion of more linear algebra constructs

Hi, thanks for graphmath! It solves a lot of problems with 3D rendering and physics simulations.

There are a few things that could be added to make this more complete for realtime 3D interactive applications, as well as 2D UIs, such as Scenic.

A few things such as Vec4, Mat22, some added functions such as trace, determinant, look_at, perspective, ortho, maybe some others, would be nice for both 3D rendering and some physics-based simulations.

The main interest I have is to unify many of these common math functions into a package that something like Scenic could utilize, as well as my own projects with OpenGL rendering. I'm not sure if this is outside the scope of this project, but if it seems it would fit, I'd be happy to open a (or some) PRs.

Vec2 rotate CCW is slightly wrong I think

Vec2d.rotate here I believe is slightly off.

I believe it should be this for CCW, but I'm not 100% sure according to this here.

def rotate( a, theta) do
  { x,y } = a
   ct = :math.cos(theta)
   st = :math.sin(theta)
  { x*ct - y*st, x*st + y*ct } # this line changed
end

The issue I'm having is that Graphmath.rotate({0,1}, :math.pi) produces {0,1} instead of {0,-1}.

Reviewing the tests, I noticed there is no case for testing the y axis, so adding something like this

@tag :vec2
@tag :rotate
test "rotate( {0,1}, :math.pi) returns {0,-1}" do
  {x,y} = Graphmath.Vec2.rotate( {0,1}, :math.pi)
  assert {0,-1} == { Float.round(x,6), Float.round(y,6)}
end

should fail. I can issue a PR for it, tomorrow just noting it. Again maybe completely wrong, not exactly the strongest in math.

Use structs instead of tuples

Sample:
defmodule Vec2 do
def x: 0.0, y: 0,0
end

I'm not sure about the cost of performance when using that, but we will have to use practicalities for example vec.x or vec.y

Round test failure on Elixir 1.4.1

   1) test round with 2 sigfigs (Graphmath.Mat33.Round_Mat33)
     test/mat33/mat33_round_test.exs:16
     Assertion with == failed
     code:  {1.1, 2.1, 3.1, 4.6, 5.7, 6.8, 7.0, 8.4, 10.0} == Graphmath.Mat33.round({1.14, 2.14, 3.14, 4.55, 5.66, 6.77, 7.03, 8.36, 9.99}, 1)
     left:  {1.1, 2.1, 3.1, 4.6, 5.7, 6.8, 7.0, 8.4, 10.0}
     right: {1.1, 2.1, 3.1, 4.5, 5.7, 6.8, 7.0, 8.4, 10.0}
     stacktrace:
       test/mat33/mat33_round_test.exs:17: (test)

Did something in the representation of floats maybe change that 4.54 is internally represented as 4.549....?

Normalize should not crash on zero quaternion

Quaternions of norm 0 cause the current normalize implementation to blow up, which is no good.

We should fix it to return a 0 quaternion in such cases, and maybe add a normalizeStrict that explodes otherwise.

Add Quatern.integrate

From here, "How to integrate a quaternion" section.

This is needed for the work on ERP, but would probably benefit others.

Split out Quatern.create variants

Quatern.create has too many variants that do similar things. This is about renaming and splitting them out to more friendly versions.

  • Quatern.create/0 to Quatern.zero/0.
  • Quatern.create/1 to Quatern.from_list/0.
  • Quatern.create/2 to Quatern.from_axis_angle/2
  • Add Quatern.from_axis_angle_packed/1

The Random Update

It's time to add more random numbers to Graphmath!

  • Add Quatern.random/0 for generating random quaternions.
  • Add Vec2.random_circle/0 for generating vec2s on a unit circle.
  • Add Vec2.random_disc/0 for generating vec2s on a unit disc.
  • Add Vec2.random_square/0 for generating vec2s on unit square.
  • Add Vec3.random_box/0 for generating vec3s inside a unit box.
  • Add Vec3.random_sphere/0 for generating vec3s on a unit sphere.
  • Add Vec3.random_ball/0 for generating vec3s on or inside the unit sphere.

Conversion between quatern and rotation matrix wrong?

Unless I'm wrong, converting to a rotation matrix and back should be reversible, right?

iex> Graphmath.Quatern.create(1,2,3,4)
...> |> Graphmath.Quatern.to_rotation_matrix()
...> |> Graphmath.Quatern.from_rotation_matrix()
{2.0, 3.0, 4.0, 1.0}

So it looks like the elements of the quatern tuple are being reversed. Is this a bug?

Make Dialyzer-safe

We want this project to pass through Dialyzer/Dialyxer without complaint.

Improve Quatern.to_rotation_matrix/1

The to_rotation_matrix/1 function should have two variants to explicitly state the output format:

  • to_rotation_matrix_33/1 to make a 3x3 matrix
  • to_rotation_matrix_44/1 to make a 4x4 matrix

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.