Hello all,
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:
[code=cpp]
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 -= longitudinalDif ference;
} while (!done);
[/code]
The code sample should generate a periodic function, the first sweep across the image should be colored red, the second sweep blue, and the third sweep green. When the amplitude of the periodic function is sufficiently low, the plot looks ok; however, when the amplitude is larger, the plot only shows the discreet truncated integer points (i.e. the plot looks better when the distance
[code=text]
D = sqrt( (x[i] - x[i - 1])^2 + (y[i] - y[i - 1])^2 )
[/code]
approaches unity.)
I'd certainly appreciate any help, particularly if it's just a nudge in the right direction. Thanks!
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:
[code=cpp]
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 -= longitudinalDif ference;
} while (!done);
[/code]
The code sample should generate a periodic function, the first sweep across the image should be colored red, the second sweep blue, and the third sweep green. When the amplitude of the periodic function is sufficiently low, the plot looks ok; however, when the amplitude is larger, the plot only shows the discreet truncated integer points (i.e. the plot looks better when the distance
[code=text]
D = sqrt( (x[i] - x[i - 1])^2 + (y[i] - y[i - 1])^2 )
[/code]
approaches unity.)
I'd certainly appreciate any help, particularly if it's just a nudge in the right direction. Thanks!
Comment