I am creating a program that generates and displays 3 dimensional graphs. I have the basics completed and the graph gets created, rotated, zoom, etc.
I want to add a crosshair feature so that one can analyze the specific data points with more detail. As the mouse moves across the canvas, two lines would form an intersection. One of the lines is parrallel to the X-axis, the other Z. On the side, I would dispaly the X&Z values as well as the Y value that is the result of the function with inputs X&Z. Hopefully this explaination is pretty straight-forward.
There are two approaches I can think of.
- Represent the lines as shapes in the 3D graph and create a custom behavior that translates them as the mouse moves. I’m a bit concerned about the performance impact of constantly translating the lines. I also want these to stretch across the entire canvas, so I guess I would need to grow them as the person zoomed out?
- Figure out how to overlay the lines on the canvas using Java2D. This would bring some complexity as the underly graph was rotated and zoomed, since I would need to draw the lines at the correct angles.
Please advise, and if you can point to example code that would be much appreciated.
James