
Quadratic Path
I was wondering if someone could give me code ( actual or just explanation ) on how to, after user puts in three values ( a,b and c..for the euqation ax^2+bx+c) , to make a picturebox follow this line.. For example say my equation is y=x^2.. How would i make a picture box follow this curve (preferably using a timer since i want it to go relatively slow). I need some explantion on how to do this.. Like i need the pic1.Left = whatever and pic2.Top = w/e... ( im new at this and im sure that is very dumb and wont work and must be much more complex).. Either way some example code with good explantion would help..Or if it is that simple please tell em
Thanks

May 04, 2003 04:21 PM
y = a*x*x + b*x + c.
Just increment x by a little bit each time, and calculate the y value through the equation. Then draw your picture at (x,y).
Just increment x by a little bit each time, and calculate the y value through the equation. Then draw your picture at (x,y).
ok..thanks..oh and btw...How do u do (x,y)..rly i have no idea how to make a picture box have a point on the form without doing .top and .left lol...whats an example of code saying X = 2 and Y = 4.. What would i use to draw the picture box on the form.??
I think your best bet would be using C++.
You know what I never noticed before?
quote:
Original post by vanillacoke
I think your best bet would be using C++.
Hmm, why?
Piknik: what language are you using? You mention forms, so I assume you are using some sort of RAD language, like VB, Delphi or C++Builder, correct?
Here's some Delphi code that will do your job:
Function Quadratic (Parameter : Integer) : Integer;Var Temp : Integer;Begin { Form AX^2 + BX + C } Temp := (Parameter * Parameter) + (5 * Parameter) + 2; Result := Temp;End;Procedure MovePicture (Var Image : TImage);Var Loop, QuadraticResult : Integer;Begin While True Do Begin If Loop = 100 Then Begin Loop := 0; End; QuadraticResult := Quadratic (Loop); Inc (Loop); Image.Left := Image.Left + QuadraticResult; Image.Right := Image.Right + QuadraticResult; Image.Bottom := Image.Bottom + QuadraticResult; Image.Top := Image.Top + QuadraticResult; End;End;
I haven't tested that, mind.
Edit: fixed type inconsistencies.
[edited by - MDI on May 5, 2003 4:29:12 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement