I've been experimenting with developing an orbital analysis program. Being a visually oriented person, I'd like to translate my (x, y) coordinate pairs to an pixel image array so I can plot the satellite ground tracks on a bitmap, JPEG, PNG, etc. If I simply truncate the values to integers, I'll only have discrete (an most likely) overlapping points rather than line segments that join pixels.
Basically, what I'd like to find out about is how to go about plotting values to pixels using a better method (and having much better plotting results/fidelity) than simply truncating.
Below is the relevant section of code:
Expand|Select|Wrap|Line Numbers
- do
- {
- for (i = 0; i < width; i++)
- {
- // Shifted so that longitude = 0 is on the prime meridian
- longitude = ((((double)i / (double)width) * 360.0) - 180.0); // [units: deg]
- longitude *= (pi / 180.0); // Convert to radians
- longitude -= m;
- latitude = (amplitude
- * sin((scale * longitude) + (raan * pi / 180.0)))
- + (0.5 * (double)height);
- if (track == 0)
- outPix.green[i][(int)latitude] = outPix.blue[i][(int)latitude] = 0;
- else if (track == 1)
- outPix.red[i][(int)latitude] = outPix.green[i][(int)latitude] = 0;
- else if (track == 2)
- outPix.red[i][(int)latitude] = outPix.blue[i][(int)latitude] = 0;
- }
- if (++track > 3)
- done = true;
- m -= longitudinalDifference;
- } while (!done);
Expand|Select|Wrap|Line Numbers
- D = sqrt( (x[i] - x[i - 1])^2 + (y[i] - y[i - 1])^2 )
I'd certainly appreciate any help, particularly if it's just a nudge in the right direction. Thanks!