This line is a solution of the Chua system of ordinary differential equations:
The first three lines and the last one are conveniently dilated, so that their two parts look like discs, and rotated, so that the two discs are aligned horizontally.
under construction
Rotation: main.py
edit# 2023, October 19. Version 231019.3
from Monocolor3Dpainter import aMonocolor3Dpainter
from Vector3D import a3Dvector, The3Dvector
from Vector2D import The2Dvector
from ODE import TheODEsolution
from time import process_time
import math
print ("Time:", process_time(), "Mathematical painter")
# The drawer:
TheDrawer = aMonocolor3Dpainter()
# The canvas:
TheCanvasStyle= "black on white" # "color", "black on white" or "white on black"
TheWidth = 500 # number of pixels
TheHeight = 195 # number of pixels
TheLengthUnit = 500 # number of pixels
TheCanvasColor = (255, 255, 255) # (red, green, blue)
TheDrawer.takesAnewCanvas(TheWidth, TheHeight, TheLengthUnit, TheCanvasStyle, TheCanvasColor)
TheDrawer.canvas.imageCenter = The2Dvector( 0.0, 0.0)
# The line of vision:
Phi = 90 # in degrees. The line of vision is parallel to the y axis.
Theta = 90 # in degrees. The line of vision is horizontal.
TheObjectCenter = The3Dvector(0, 0, 0)
TheDistance = 100 # The distance between the object center and the optical center.
TheZoom = 9.7
Psi = 0 # in degrees.The angle of rotation of the image around the line of vision.
TheDrawer.choosesApointOfView(TheObjectCenter, TheDistance, Phi, Theta, Psi, TheZoom)
# The paintbrush:
TheDrawer.paintbrush.color = (0, 0, 0) # Black
TheDrawer.paintbrush.lineHalfWidth = 0.004 # (The line half width * the length unit) is the
# number of pixels in the half width of the line.
TheDrawer.brush3D.lineFringeRelativeWidth = 0.5
TheDrawer.brush3D.lineDepth = TheDrawer.paintbrush.lineHalfWidth*(1+TheDrawer.brush3D.lineFringeRelativeWidth)
TheDrawer.brush3D.lineOpacity = 0.3
TheDrawer.brush3D.intensity = 0.1
# The Chua system (Smale version):
# dx/dt = a(y - x^3/16 + x/6)
# dy/dt = x - y + z
# dz/dt = -by
# For example b=28 and a =15.4
# Chua(u) is the speed vector v of a moving point at position u in a Chua system with a and b as parameters:
a = 15.446
b = 28.0
def Chua(u):
v = a3Dvector()
v.x = a*(u.y - u.x*u.x*u.x/16 + u.x/6)
v.y = u.x - u.y + u.z
v.z = -b*u.y
return v
# The line:
TheNumberOfPoints = 150000 # The number of points which determine the line
TheInitialPosition = The3Dvector(1.1825893595123613, 0.23472549987537494, -0.14078614109165155)
The_dt = 2E-5 # The time between two steps of computation
TheDelay = 0 # The delay between the initial position and the first point.
TheNumberOf_dt_betweenPoints = 250
print("Time:", process_time(), "The drawer calculates the solution. a =", a)
TheLine = TheODEsolution(Chua, TheInitialPosition, The_dt, TheDelay, TheNumberOfPoints, TheNumberOf_dt_betweenPoints)
print("Time:", process_time(), "The last point of the line. x:", TheLine.point[TheLine.numberOfPoints - 1].x,
"y:", TheLine.point[TheLine.numberOfPoints - 1].y, "z:", TheLine.point[TheLine.numberOfPoints - 1].z)
# The line is conveniently rotated and dilated:
TheLine = TheLine.ZaxisRotated(-33 * math.pi / 180)
TheLine = TheLine.XaxisRotated(+8 * math.pi / 180)
TheLine = TheLine.YaxisRotated(+15 * math.pi / 180)
TheLine = TheLine.Xdilated(3)
TheLine = TheLine.YaxisRotated(-43 * math.pi / 180)
TheLine = TheLine.Ydilated(3)
# The animation:
TheNumberOfImages = 720
for i in range(TheNumberOfImages):
Phi = 90 + 0.5*i
TheDrawer.choosesApointOfView(TheObjectCenter, TheDistance, Phi, Theta, Psi, TheZoom)
TheDrawer.takesAnewCanvas(TheWidth, TheHeight, TheLengthUnit, TheCanvasStyle, TheCanvasColor)
print("Time:", process_time(), "The drawer draws the image", i, ". Phi =", Phi)
TheDrawer.drawsA3Dline(TheLine)
# The folder 'Chua' for the images shall have been created:
TheDrawer.givesApainting("Chua/im"+str(1000+i)+".png")
# str(1000+i) is here because * in imagemagick works with a lexicographic order.
print("Time:", process_time(), "Good bye")
# 720 images are saved in the folder 'Chua'. With imagemagick, they can be united to make a GIF:
# convert -delay 4 -loop 0 im*.png ChuaAnimation.gif
The zoom: main.py
editThe flow: main.py
editOther files
editThis program requires the following additional files: Painter.py, Line2Ddrawer.py, Vector2D.py, Monocolor3Dpainter.py, Vector3D.py, Line3D.py, DepthMatrix.py, ODE.py and Palette.py. They are all on this pageĀ : User:Thierry Dugnolle/Python/Mathematical painter.