TPU ChatChat on IRC
Internet Relay Chat?
Java Applet client
Who's on IRC?
Posted by Kruptos [send private reply] at June 28, 2003, 01:43:54 PM Hello Everyone,
I'm sure this is a noobish question but as I haven't needed to do much graphical progamming in the past I haven't really been compelled to find a solution to my problem....which is: Is it possible to define a 2d cartesian plane where coordinates are on a smaller scale than the actual pixel values of the screen? I realize I'm phrasing this badly so please bear with me, heres my situation.
I'm writing a program to model a number of situations that come up in typical Newtonian physics. The program allows the user to defined their own 2d shapes, choose their properties, and then watch what happens to them when they collide/explode/come near eachother, etc. I haven't worked out all of the details, but one of the main problems I'm having is working out how to plot graphics that have decimal coordinates, something which often occurs when you plug a bunch of arbitrary values into an equation.
Example: A floating orb X has an initial velocity of 22m/s and a constant acceleration of 1.5m/s^2, so after 5 seconds have elapsed the orb should have a velocity of 29.5m/s and have moved 128.75m (this is in a perfect world with no gravity, air resistance, friction, etc.). The way I would generally do this would just be to plot the orb at (129,0), assuming it started at (0,0)--but what do I do if I need that inreased level of accuracy...ie: need to include the 0.75m instead of just rounding up? Do I need to define my own coordinate plan and write graphics functions accordingly? I assume there must be an easier way to do it...or rather I hope.
Any help would be appreciated.
Posted by Kruptos [send private reply] at June 28, 2003, 02:03:57 PM I also wanted to add that though this is school-related, its not a homework problem. Its something I volunteered to do for extra credit over the summer but also a question which has applications in other programs I'm working on. Thanks.
Posted by Psion [send private reply] at June 28, 2003, 04:06:11 PM What do you mean "need that increased level of accuracy"? Your monitor can't do better than pixels....
Posted by Neumann [send private reply] at June 28, 2003, 09:03:49 PM Defining your own coordinate plan would be the simplest (if not the only) way to proceed. Writing the graphic functions for another plan might be as simple as:
procedure PixelSet(X: integer, Y: integer)
NativePixelSet(0.5 * X, 0.5 * Y);
... or maybe I don't understand your problem correctly.
OpenGL has some function to help you with custom coordinate planes and heck! even QBasic had that kind of functions too.
Posted by 01011010 [send private reply] at June 30, 2003, 01:04:04 PM Assuming I understand your problem correctly :)
Calculate and do everything else in your own defined coordinate system. When you have to display it onto the screen, scale and/or round or truncate the coordinates into integer and put them onto the screen. Zooming and moving point of view is important, too. Imagine, in the real life, if we have to observe the movement of an object, we also have to follow it and sometimes come closer or farther to have a better view.
Treat those "complex" numbers like integers by rounding or truncating. The screen certainly cannot exactly display everything in your virtual world. However, zooming and moving function will help the user to view better.
Posted by Kruptos [send private reply] at July 02, 2003, 11:23:01 PM I've thought of another way of doing this, but I appreciate all of your help. Thanks.
Register as a new user