Can you vote for this Quality report, please? It's a serious issue where math done with TVector3D gives the wrong results - completely wrong. The reason is that it is not a 3D vector, despite its name, but a 4D vector. Any normal math you do, such as adding a scaled vector to a 3D point, gives the wrong result.

Can you vote for this Quality report, please? It's a serious issue where math done with TVector3D gives the wrong results - completely wrong. The reason is that it is not a 3D vector, despite its name, but a 4D vector. Any normal math you do, such as adding a scaled vector to a 3D point, gives the wrong result.

Eg, for the expression "Pt3D + Vec3D * Scalar" where Pt3D is TPoint3D.Create(0,0,0), Vec3D is TVector3D.Create(1,0,0) and Scalar is Single = 12, you would expect a resulting 3D point value of (12,0,0), right? No. You get (1,0,0). Which is wrong.

Even worse, TPoint3D is the stand-in for a real 3D vector. System.Math.Vectors goes so far as to deprecate vector operations like a cross product on the vector type, and puts them on the point type instead - something that makes no sense.

Reading this code with some knowledge of 3D math makes my head hurt. Using it is even worse (I just fixed several bugs by replacing my usage of TVector3D with TPoint3D, despite wanting a 3D vector, and looking at the RTL/FMX (and now my) code where things are cast to and from points and vectors just to get the right behaviour... argh.) However, it can be improved easily, and there are recommendations for the appropriate changes in the Quality report. There is also a simple console program attached to the report showing both the expected and incorrect behaviours.

https://quality.embarcadero.com/browse/RSP-9749
https://quality.embarcadero.com/browse/RSP-9749

Comments

  1. I do wish FMX was more open to contributions. In fact I'd love to see it placed on a server where you could submit patches. I'd happily rewrite the vector classes and their use throughout the entire library, just for my own satisfaction. And the render tree/sorting. And lack of orthographic camera. And...

    ReplyDelete
  2. David Millington FMX still is not at the level of what was available in some Turbo Pascal libraries for 3D... back in the day of Wireframe CAD . The rendering libraries have evolved, but the basics of linear algebra have not. So it's really a case of NIHS, there were literally dozens of libraries they could have leveraged.

    ReplyDelete
  3. Eric Grange So what can we do about it? I feel like we need some kind of community movement to improve the thing.

    ReplyDelete

Post a Comment