1. Problem with GDI & sin() (double & int problems)

sorry, i forgot the subject.. i am a lil bit tired and busy..

hello, i got a problem,

i want to draw the graph of mathematical functions like sin or cos or

parabel's ( f(x) = x^2 ).

i use a metafile object with class CPaintDC.

CPaintDC dc(GetDlgItem(IDC_SURFACE));

the point (0;0) is in the left up corner, thats ok....

i need it in the middle so i get the middle of the metafile object like

this:

int null_x, null_y;

CWnd *pSrf;

CRect SrfRect;

pSrf = GetDlgItem(IDC_SURFACE);

pSrf->GetClientRect (SrfRect);

null_x = SrfRect.right / 2;

null_y = SrfRect.bottom / 2;

// blah...

so,

now ill start to trying to draw the sin();

i tried it so:

int x,px,py; // px and py are the points wich i use to draw..

px = null_x + x;

py = null_y - (sin(x * (pic / 180))); // yeah, i know that i dont use

amplitude in this function, but i do in the real code!

so, now appears the problem,

sin() returns double value, thats ok, but

CDC::LineTo() requires int value!

so if i declare py as double, its not the solution!

when i give double value to CDC::LineTo() it would be converted to int.. so

its impossible to draw curve this way, becaue 0.5 as double will be 0 as

int!

so i tried to round the 0.5, but now i dont know why, i see not a sin curve,

i see a line...lol

i did my own function to round values:

its quiet easy and possible wrong.. but it works

int round(double x)

{

double b;

int c;

c = x;

b = x - c;

if ( b < 0.5 )

return c;

else

return c + 1;

so, ill hope you can understand me and i hope that i dont forget something..

:-)

maybe one of you can help me, thank you !

(please dont tell me how bad my grammer and spelling is..thank you)

... Christian Meyer

2. FS: MUCH Atari ST stuff

3. Rich Edit Control Printing Problem (like the print preview problem)

4. setting the lpr-switches variable

5. Timing problems, windows resource managment problems??

6. nested tabular/arrays: how to increase row spacing at outer level?

7. Problem: Require to create null PWL files or other solution for password syncronization problem

8. Password protect pages without Session objects???

9. Typed library problems, client problems.

10. More help needed for modem problem (Tapi multi modem support problem)

11. Problem using this function to fill LINEDEVCAPS struct - from Chris Sells book - problem on Windows 2000

12. Problem with Modal Dialog in NT3.51 (don't see problem in NT4.0)

13. Newbie problem: control creating problem