Function G2(StartX, StartY, EndX, EndY, Radius)

Blitz3D Forums/Blitz3D Programming/Function G2(StartX, StartY, EndX, EndY, Radius)

Well, what your function fails to do it determine what side of the arc the raduis is on. From that information you have given, it could be either side.

Now, once you have figured which side the arc should bend away from, you need to find the centre point of the start and end co-ords. Very easy to do.

MiddleX = StartX + ((EndX - StartX)/2)
MiddleY = StartY + ((EndY - StartY)/2)


That will give you the middle co-ords. You now need to find the angle the line above is going at. I believe the ATan2 function gives you this angle.

http://www.blitzbasic.com/b3ddocs/command.php?name=ATan2&ref=2d_a-z

Once you have the angle, work out the perpendicular (90 degree) angle to that. Call it "perp_angle" just for example sake. Then from the middle co-ords you worked out, pull away from the mid point at the "perp_angle", to give you your point to start to draw the arc from, draw_x, and draw_y for examples sake.

From the point you worked out above, you will need to work out the start angle and end angle. You do this by working out the angle between the draw_x and draw_y. From these points:

for loop = start_angle to end_angle

plot cos(loop)*raduis,sin(loop)*raduis

next

that should draw your curve :o)

I may have messed up the order of sin and cos, but the theory should work fine.