• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

C math

Messages
14
Country
us-texas
Have this code which is part of a string callback:

FLOAT64 angle, alt, alt1, alt2;
lookup_var(&baro_alt);
alt = (FLOAT64)baro_alt.var_value.n;
alt1 = 20936200;
alt2 = alt1 + alt;
angle = alt1 / alt2;
sprint(pelemnt->string, "%6.3f" , angle);
return angle;

if the altitude is 10000 ft the anwser for angle should be .999522586
it always return 1.0 no matter what I do. I get the correct value at alt2 but it is when I divide it doesnt come out correct.
I need the precision of the decimal places for this string.
Any suggestions to get it to stop rounding up or losing my decimal spaces?


Thanks,
Chris
 
This is the offending line:
sprint(pelemnt->string, "%6.3f" , angle);

If you want all those decimal places, you have to make the specification provide for it.
The 6.3 part specifies 6 digits, with 3 of them being to the right of the decimal point.
You want something like:
sprint(pelement->string, "%11.9f" , angle);

Doug
 
Doug,

Thanks that was it. Didnt know by having too little decimal places it would actually effect the math.

One more question.
Is it possible to actually shift a image determined by a variable?
Example in a HUD you have the horizon which rotates at x=480 y =270.
Depending on the altitude you have the certain angle to the horizon. At 25000 ft the angle should be around 2.8 degrees. So i need to shift the rotation point of the image according to the angle * pixels. So I need to shift it 61 pixels down so the horizon of the HUD actually stays with the horizon and not the fixed rotation point. Is this possible?

Thanks,
Chris
 
Because the earth is round, a HUD horizon line will not be aligned on the visible horizon at high altitude. It should be spot on when the visible horizon is close like at 200 -1000 ft AGL or AMSL, but it will be above the visible horizon at higher altitudes when the distance to the visible horizon increases.. And it should stay there in a climb. If it moves when the pitch angle is changed, the problem is inaccurate scaling in terms of pixels per visual degree and that has to do with the HUD planar geometry with respect to the specified eye position in the model. If using Track-IR where the eye position changes, it could be a function of inaccurate collimation due to the distance of the planar ahead of the eye position. The planar needs to be about 25m ahead in which case an inch of head movement translates into a milliradian of collimation error, which is not significant except in weapon aiming error terms.

The angular difference between the HUD horizon line and the visual horizon you are seeing is probably correct. If the flight path marker is on the HUD horizon line with zero vertical speed, the HUD line is most likely accurate, provided that it does not diverge when climbing or diving.

Roy
 
Roy,
Thanks for the response. Im glad it works that way because I dont know if its possible to do what I wanted anyways!!

Chris
 
Back
Top