Skip to content

Commit 0eb2074

Browse files
committed
Vertex: override the toString() method
1 parent 4ff7ae6 commit 0eb2074

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • src/main/java/com/github/stephengold/joltjni

src/main/java/com/github/stephengold/joltjni/Vertex.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,28 @@ public Float3 getVelocity() {
227227
return result;
228228
}
229229
// *************************************************************************
230+
// Object methods
231+
232+
/**
233+
* Return a string representation of the vertex, which is unaffected. For
234+
* example:
235+
* <pre>
236+
* Vertex{(0.0 2.0 0.0) v(0.0 -1.0 0.0) im=0.5}
237+
* </pre>
238+
*
239+
* @return the string representation (not {@code null}, not empty)
240+
*/
241+
@Override
242+
public String toString() {
243+
Float3 p = getPosition();
244+
Float3 v = getVelocity();
245+
float im = getInvMass();
246+
String result = "Vertex{(" + p.x + " " + p.y + " " + p.z
247+
+ ") v(" + v.x + " " + v.y + " " + v.z + ") im=" + im + "}";
248+
249+
return result;
250+
}
251+
// *************************************************************************
230252
// native private methods
231253

232254
native private static long createCopy(long originalVa);

0 commit comments

Comments
 (0)