Title | Draw a hypotrochoid |
Keywords | hypotrochoid, curve |
Categories | Graphics |
|
|
The hypotrochoid is represented by the following parametric functions as t ranges from 0 to 2 * Pi.
|
|
' The parametric function X(t).
Private Function X(ByVal t As Single) As Single
X = 6 * Cos(t) + 5 * Cos(3 * t)
End Function
' The parametric function Y(t).
Private Function Y(ByVal t As Single) As Single
Y = 6 * Sin(t) - 5 * Sin(3 * t)
End Function
|
|
In the form's Paint event handler, the program calls the DrawCurve subroutine to connect points defined by these functions.
|
|
' Draw the curve on the form.
Private Sub DrawCurve(ByVal start_t As Single, ByVal stop_t _
As Single, ByVal dt As Single)
Dim t As Single
Cls
CurrentX = X(start_t)
CurrentY = Y(start_t)
t = start_t + dt
Do While t < stop_t
Line -(X(t), Y(t))
t = t + dt
Loop
Line -(X(stop_t), Y(stop_t))
End Sub
|
|
See my book Visual Basic Graphics Programming for more information on drawing other interesting curves normally or transformed (stretched, squashed, or rotated).
|
|
|
|