Let's imagine to draw arc. Assume center of the arc as x = 200, y = 300, start angle a1 = -30 and end angle = -60. In mathematics, y axis goes up. But in Small Basic GraphicsWindow, y axis goes down. So sign of angle becomes opposite. If you don't use trigonometric function, so use only 0, 30, 45, 60, 90, ...[degree]. Between these angles you can calculate height s from width c of the triangle while three edges of triangle r, c, s such as picture below have relationship r2 = s2 + c2 .
But for any angle, use trigonometric function (sin, cos).
Be careful that trigonometric function needs [radian] but [degree] for Small Basic language.
You can use Math.GetRadians(degree) to convert from [degree] to [radian].
gw
=
GraphicsWindow
.
Width
gh
Height
DrawGrid
(
)
x
200
y
300
r
DrawArcwoTrigo
Program
Delay
3000
Clear
a1
-
30
a2
60
DrawArcwTrigo
Sub
' draw arc without trigonometric functions
Title
"Arc without Trigonometric Functions"
c1
*
Math
SquareRoot
3
/
2
' a1 = -30
c2
' a2 = -60
r2
Power
,
For
c
To
Step
1
s
x2
+
y2
If
Then
PenColor
"Gray"
DrawLine
Else
"Black"
x1
y1
EndIf
<
EndFor
EndSub
' draw arc with trigonometric functions
"Arc with Trigonometric Functions"
a
0.3
Cos
GetRadians
Sin
"MediumSeaGreen"
BrushColor
_x
0
50
DrawText
4
"x"
_y
"y"
Nonki Takahashi edited Revision 3. Comment: re-uploaded image
Nonki Takahashi edited Revision 1. Comment: typo
Nonki Takahashi edited Original. Comment: minor change
This article is from social.msdn.microsoft.com/.../611f60a6-b202-4c6f-aaeb-695570af94e8 .