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

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here's my start
it's very flawed but the math should be all there
Mouse wheel adjusts the radius and I haven't got the
angles to the start and end point from the center
the curve also doesn't follow the mouse from the center
like it should

Graphics 640, 480, 32, 2
SetBuffer BackBuffer()
startx=320
starty=240
Radius=100
While Not KeyHit(1)
	LockBuffer()
	ms = MilliSecs()
	mx = MouseX()
	my = MouseY()
	radius = MouseZ()*10
	
	chord = Sqr( ((startx - mx)*(startx - mx)) + ((starty - my)*(starty - endy)))
	MidX=Sqr((startx - mx)*(startx - mx))
	MidY=Sqr((starty - my)*(starty - my))
	MidChord= chord/2
	sideB=Sqr((Radius*Radius)-(MidChord*Midchord))
	angleToCenter = ATan2(mx,my)-90
	RadX=Sin(angleToCenter)*Radius+MidX
	RadY=Cos(angleToCenter)*Radius+MidY
	;angleToStart=atan2() Radx and rady need to be transformed to center and startx and starty transformed
	;angleToEnd=atan2()Radx and rady need to be transformed to center and mx and my transformed
	;For i = angleToStart to angleToEnd
	For i = angleToCenter-30 To angletocenter+30
		WritePixel RadX+Sin(i)*Radius,RadY+Cos(i)*Radius,$FFFFFF
	Next
	ms = MilliSecs() - ms
	UnlockBuffer()

	Flip 0
	Cls
Wend
End