[go: up one dir, main page]

0% found this document useful (0 votes)
10 views2 pages

Fractals

The document discusses the behavior of plotted points based on specific equations that can lead to various patterns, including cycles, chaos, or strange attractors. It provides a code example that demonstrates how to plot these points efficiently using a Timer to enhance performance. The code generates and displays 1,000 points at a time on a Bitmap for visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Fractals

The document discusses the behavior of plotted points based on specific equations that can lead to various patterns, including cycles, chaos, or strange attractors. It provides a code example that demonstrates how to plot these points efficiently using a Timer to enhance performance. The code generates and displays 1,000 points at a time on a Bitmap for visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

fractals

If you plot a sequence of point (x1, y1), (x1, y2), ..., the points can settle into
one of several patterns. For example, they can enter a repeating cycle, tend
towards infinity, or look chaotic. Another option is following a strange attractor.
In that case, the points clearly follow some pattern but not an obvious repeating
cycle.

This example plots points given by the equations:

X' = A0 + A1 * x + A2 * x * x + A3 * x * y + A4 * y + A5 * y * y
Y' = A6 + A7 * x + A8 * x * x + A9 * x * y + A10 * y + A11 * y * y

For various values of A1, A2, ... A11.

The program uses a Timer to plot points. The following code shows the Tick event
handler that draws the curve. It plots 1,000 points at a time to improve
performance and reduce flicker. For each iteration, the routine generates the next
(X, Y) point and draws it on the Bitmap named m_Bitmap. After it has finished its
1,000 points, it draws the Bitmap onto the picCanvas control so you can see the
result.

Private X As Double
Private Y As Double

Private Sub tmrDrawPoint_Tick(ByVal sender As _


System.Object, ByVal e As
System.EventArgs) Handles tmrDrawPoint.Tick
For i As Integer = 1 To 1000
Dim new_x As Double = A(0) + A(1) * X + A(2) * X * _
X + A(3) * X * Y +
A(4) * Y + A(5) * Y * Y
Dim new_y As Double = A(6) + A(7) * X + A(8) * X * _
X + A(9) * X * Y +
A(10) * Y + A(11) * Y * Y
X = new_x
Y = new_y

Dim pix_x As Integer = (X - m_Wxmin) / m_Wwid * _


m_Wid
Dim pix_y As Integer = m_Hgt - (Y - m_Wymin) / _
m_Whgt * m_Hgt - 1
If (pix_x >= 0) AndAlso (pix_x < m_Wid) AndAlso _
(pix_y >= 0) AndAlso (pix_y < m_Hgt) _
Then
m_Bitmap.SetPixel(pix_x, pix_y, Color.Blue)
End If
Next i

' Display the result.


Dim gr As Graphics = picCanvas.CreateGraphics()
gr.DrawImage(m_Bitmap, 0, 0)
gr.Dispose()
End Sub

You might also like