jMonkeyEngine / jmonkeyengine

A complete 3-D game development suite written in Java.
http://jmonkeyengine.org
BSD 3-Clause "New" or "Revised" License
3.74k stars 1.12k forks source link

math classes should override toString() #2246

Closed stephengold closed 1 month ago

stephengold commented 2 months ago

Currently, when you print a com.jme3.math.Triangle using System.out.println(t), you get an opaque identifier generated by Object.toString(), such as "com.jme3.math.Triangle@5b33a14a".

For debugging, it would be helpful to override toString() so that Triangle.toString() would generate something like

Triangle [P1: (-0.22671932, 0.5148976, -0.52107906)  
             P2: (-0.22671932, 0.014897585, -0.52107906)
             P3: (-0.22671932, 0.014897585, -0.45209116)]

If the override were in "AbstractTriangle.java" then it would benefit other implementations of AbstractTriangle (though I'm currently not aware of any).

Similar enhancements should also be made to other com.jme3.math classes, such as Line, LineSegment, and Rectangle.