10-13-2024, 03:28 AM
(10-13-2024, 03:11 AM)bplus Wrote: So your East = 0 but you go Counter-Clockwise Yikes!
Like to see an Atan2 for that! LOL
Your wish is my command. It's just a little rotation of the result.
Just use the Atan command packaged here so it gives results in Degrees as you'd normally want to see and work with.
Code: (Select All)
Screen _NewImage(1280, 720, 32)
$Color:32
PieSlice 100, 100, 100, 45, 0, Red
PieSlice 200, 200, 50, 270, 120, Green
PieSlice 300, 300, 50, 120, 270, Gold
Print Atan(100, 100, 171, 29) '45 degree coordinates
Print Atan(100, 100, 100, 150) '270 degree coordinates
Print Atan(100, 100, 75, 57) '120 degree coordinates
Function Atan (x1, y1, x2, y2)
Atan = (360 - _R2D(_Atan2(y2 - y1, x2 - x1))) Mod 360
End Function
Sub PieSlice (cx As Long, cy As Long, r As Long, startAngle As Long, endAngle As Long, c As _Unsigned Long)
Dim As Long x, y, x1, y1
If startAngle > endAngle Then endAngle = endAngle + 360
x1 = Sin(_D2R(startAngle + 90)) * r
y1 = Cos(_D2R(startAngle + 90)) * r
Line (cx, cy)-Step(x1, y1), c
For i = startAngle To endAngle Step Sgn(endAngle - startAngle)
x = Sin(_D2R(i + 90)) * r
y = Cos(_D2R(i + 90)) * r
Line -(cx + x, cy + y), c
If x <> x1 And y <> y1 And xt = 0 Then 'chose a point inside the arc to fill
xt = Sin(_D2R(i + 90)) * r / 2
yt = Cos(_D2R(i + 90)) * r / 2
End If
Next
Line -(cx, cy), c
Paint (cx + xt, cy + yt), c
End Sub