Help me convert a short math code from VB to C++
With this code you can get i.e. a circle to go from one point on the screen to another. The "Length" stuff makes it so that the circle keeps the same speed.
X1= point #1, x
Y1= point #1, y
X2= point #2, x
Y2= point #2, y
It has to got two different was of counting depenfing if X1X2. The problem I have is with the intergers and doubles.
I don''t know witch need to be what. Can anyone help me?
Here is the code:
length = Sqr((Abs(Y1 - Y2)) ^ 2 + (Abs(X1 - X2)) ^ 2)
If X1 < X2 Then
For X = 0 To (X2 - X1) Step ((X2 - X1 + 1) / length)
yl = (((Y2 - Y1) / (X2 - X1)) * X) + Y1
xl = X1 + X
end if
If X1 > X2 Then
For X = 0 To (X1 - X2) Step ((X1 - X2 + 1) / length)
yl = (((Y2 - Y1) / (X2 - X1)) * -X) + Y1
xl = X1 - X
end if
Form1.Circle (xl, yl), 2, RGB(1,255,1) <- not needed to convert
"To some its a six-pack, to me it's a support group."
Well, I think your question is basically "Do I use integers or doubles?" I say, use doubles. Although, it should be faster if you use singles. Remember, if you need to convert back to an int or a long, you just use cint() or clng().
------------------------
Captured Reality.
------------------------
Captured Reality.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement