Giter VIP home page Giter VIP logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
I cannot seem to reproduce this bug.

For me the result is 34481, which is 0.5 % error. This is within the expected 
limits.

See attached test.c, I compiled it under x86_64 using GCC with this command:
gcc -o test test.c fix16.c fix16_trig.c fix16_sqrt.c 
./test
sqrt: 113512 atan2: 34481


Original comment by Petteri.Aimonen on 11 Apr 2013 at 3:07

Attachments:

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
The compiler i'm using is MSVC 2008 Express Edition version 9.0

Original comment by [email protected] on 15 Apr 2013 at 11:03

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
Can you compile the test.c included earlier and tell us its output?

Original comment by Petteri.Aimonen on 15 Apr 2013 at 12:55

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
sqrt: 113512 atan2: -2147432177

Original comment by [email protected] on 15 Apr 2013 at 1:29

from libfixmath.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 24, 2024
I'm also having difficulties with atan2. Here is the code I use to compare 
atan2 for double and Fix16. I cannot expect Fix16 to be as accurate as double, 
but there seems to be an offset of about 0.1 pi for some values. Here is the 
code I use:

#include <cmath>
#include <fstream>
#include <iostream>

#include <fix16.h>
#include <fix16.hpp>

int main()
{
  unsigned int n = 1000;
  std::ofstream file("out.dat");
  std::ostream& out(file);//(std::cout);
  for(unsigned int i = 0; i <= n; i++)
  {
    double d = M_PI/2.*i/1000;
    double s = sin(d);
    double c = cos(d);
    double a = atan2(s,c);
    Fix16 df(d);
    Fix16 sf(df.sin());
    Fix16 cf(df.cos());
    Fix16 af(sf.atan2(cf));
    out << d
        << " " << a
        << " " << (double)af
        << std::endl;
  }
  return 0;
}

I used gnuplot for plotting the results, here is the command:

plot "out.dat" u 1:2 w l title 'double', "out.dat" u 1:3 w l title 'Fix16'

I have attached the plot.

Original comment by [email protected] on 4 Feb 2014 at 9:10

Attachments:

from libfixmath.

Related Issues (20)

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.