Giter VIP home page Giter VIP logo

Comments (8)

bcoconni avatar bcoconni commented on June 4, 2024 1

Last call before departure closing the issue as won't fix 😃

from jsbsim.

seanmcleod avatar seanmcleod commented on June 4, 2024 1

I'm assuming he means the method should be along the following lines:

bool operator==(const FGColumnVector3& b) const {
   return fabs(data[0] - b.data[0]) < 1e-13 && fabs(data[1] - b.data[1]) < 1e-13 && 
      fabs(data[2] - b.data[2]) < 1e-13;
}

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

I'm not sure I'm getting your point: your statement is too vague. Can you please point at a place in the code where you think the usage of == is "not right" ?

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

Ping !

@jinzhu1911 It's been one month since I asked you some clarifications but got no answer. Could you please be more specific ?

from jsbsim.

jinzhu1911 avatar jinzhu1911 commented on June 4, 2024

In the function Comparison operator.

 bool operator==(const FGColumnVector3& b) const {
    return data[0] == b.data[0] && data[1] == b.data[1] && data[2] == b.data[2];
  }

from jsbsim.

agodemar avatar agodemar commented on June 4, 2024

@jinzhu1911 Your answer isn't clear. Could you elaborate?
Please, do keep in mind that this is not the place to be cryptic.

from jsbsim.

jinzhu1911 avatar jinzhu1911 commented on June 4, 2024

in the function Comparison operator.
bool operator==(const FGColumnVector3& b) const {
return data[0] == b.data[0] && data[1] == b.data[1] && data[2] == b.data[2];
}

I'm assuming he means the method should be along the following lines:

bool operator==(const FGColumnVector3& b) const {
   return fabs(data[0] - b.data[0]) < 1e-13 && fabs(data[1] - b.data[1]) < 1e-13 && 
      fabs(data[2] - b.data[2]) < 1e-13;
}

Yes, I mean this. Thanks very much!

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

I'm assuming he means the method should be along the following lines:

bool operator==(const FGColumnVector3& b) const {
   return fabs(data[0] - b.data[0]) < 1e-13 && fabs(data[1] - b.data[1]) < 1e-13 && 
      fabs(data[2] - b.data[2]) < 1e-13;
}

Yes, I mean this. Thanks very much!

Well FGColumnVector3::operator== tests equality of two FGColumnVector3 instances which is different from testing if they are almost equal. Test frameworks often provide the latter functionality but in that case, they let the user specify the precision with which the values are compared. C++ does not allow to specify an additional parameter to operator==.

If that really is a problem, I'd rather add a function such as

bool AlmostEqual(const FGColumnVector3& a, const FGColumnVector3& b, double precision) {
  return fabs(a[0]-b[0]) < precision && fabs(a[1]-b[1]) < precision && fabs(a[2]-b[2]) < precision;
}

and leave FGColumnVector3::operator== as it is.

from jsbsim.

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.