Giter Site home page Giter Site logo

Comments (3)

basicNew avatar basicNew commented on July 20, 2024

Couple of thoughts:

  1. The 2.7755575615628914E-17 vs 0.0 looks like an expected rounding error. Comparing floats is a hard thing, as IEEE floating point arithmetic can't represent the whole Real space (see e.g. https://docs.python.org/2/tutorial/floatingpoint.html). To cope with this testing frameworks have a way to assert equality in a given delta (see e.g. http://stackoverflow.com/questions/7554281/junit-assertions-make-the-assertion-between-floats)
  2. The 1.0714285714285714 vs 1.0 does seem suspicious. Are you sure there is no coding error?
  3. getters and setters are also good to isolate your class implementation from itself, so you could change this.r for this.getR()

from quaternion.

julianmateu avatar julianmateu commented on July 20, 2024
assertEquals(new Quaternion(1, 2, 3, 4).multiply(new Quaternion(
                        ((double)1.0)/28, ((double)-2.0)/28, ((double)-3.0)/28, ((double)-4.0)/28)),
                new Quaternion(1, 0, 0, 0)); // Multiplying by right inverse.

The problem with the 1.0714285714285714 vs 1.0 was because the norm of the quaternion was 30, not 28.

The 2.7755575615628914E-17 vs 0.0 was a rounding error problem, so I created a new assert with a tolerance, comparing each component of the two quaternions with an assertEquals.

from quaternion.

basicNew avatar basicNew commented on July 20, 2024

👍

from quaternion.

Related Issues (1)

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.