graphing vectors with two incompatible scales
I'm looking for a better way to write code that is graphing vectors in 2D.
The location of the vectors is on a map, scale is thousands of meters. So you first pick a location. Then the magnitude of the vector is proportional to the velocity of something (air, water, whatever). This scale is radically different than the scale of the map, so the vectors have to be scaled up. x&y for some of these graphs is not the same either.
What I figured out in OpenGL is to compute the initial location of the vector, then translate that location to zero, and (the ugly part) rescale using the inverse of the physical scale to get back physical pixels, because I need the vector to be, say 15 pixels long if it's 1 meter/sec. This scaling is very ugly, because to find the scale for x and y, I need the physical size of the screen. It just seems there should be a cleaner way of doing it.
Vector has two points, a, b
a is fine
b = a + physical pixels * different scale
It is the fact that the addition uses two totally different scales that means that there is no simple matrix operation that does the job.
I have considered as a way of cleaning this up, doing the manipulation outside opengl, and keeping the OpenGL scale as follows:
glOrtho(0, width, 0, height, -100, 100);
so that the openGL scale is just physical pixels. But I am hoping that there is something I do not know about OpenGL that will make this elegant and simple.
Re: graphing vectors with two incompatible scales
try glScalef( xscale, yscale, zscale)
zscale would be 1.0 in your case.