User:Thierry Dugnolle/Python/The structure of diamonds

A very little diamond.

Each line represents a bond between two carbon atoms. The rotation is around the second-order symmetry axis of the structure.


Inside a diamond

The observer is at the center of a very little diamond (21 x 21 x 21 cubic cells). The rotation is around the second-order symmetry axis of the structure.


Inside a diamond

The rotation is around the third-order symmetry axis of the structure.


Traveling inside an infinite diamond


Promenade in a diamond


Ascension in a diamond


Upside Down in a diamond


The cubic cell of the structure of diamonds 1


The above one is seen from afar, like with a telescope. The below one is the same one without its spikes, seen up close:


The cubic cell of the structure of diamonds 2


Eight such cubic cells can be stacked :



In the structure above, the interior spikes are conserved, only the exterior ones are suppressed.


27 = 3 x 3 x 3 cells


Rotation around the third-order symmetry axis


main.py

edit
# 2023, October 8. Version 231008


from Line3Ddrawer import a3DlineDrawer
from Vector3D import a3Dvector, aNew3Dvector
from Vector2D import aNew2Dvector
from Lattice import TheCubicCell, TheDiamondCell
from time import process_time

print ("Time:", process_time(), "Mathematical painter")

# The drawer:
TheDrawer = a3DlineDrawer()

# The canvas:
TheCanvasStyle= "black on white" # "color", "black on white" or "white on black"
TheWidth = 300 # number of pixels
TheHeight = 300 # number of pixels
TheLengthUnit = 400 # number of pixels
TheCanvasColor = (255, 255, 255) # (red, green, blue)
TheDrawer.takesAnewCanvas(TheWidth, TheHeight, TheLengthUnit, TheCanvasStyle, TheCanvasColor)
TheDrawer.canvas.imageCenter = aNew2Dvector( 0, 0)

# The line of vision:
# The angle (in degrees) of the line of vision relative to the z axis:
Theta = 90
# The angle (in degrees) between the projection of the line of vision on the xy plane
# and the x axis:
Phi = 90
# The position of the optical center is determined by the position of the object,
# the direction of the line of vision and the distance between the object and
# the optical center:
# The position of the center of the object:
TheObjectCenter = aNew3Dvector(0, 0, 0)
# The distance between the object center and the optical center:
TheDistance = 7.5

# The zoom = 1 means that the image is neither reduced nor enlarged, > 1 that it is enlarged,
# > 0 and < 1 that it is reduced:
TheZoom = 1

# Psi is the angle of rotation of the image around the line of vision.
Psi = 0

TheDrawer.choosesApointOfView(TheObjectCenter, TheDistance, Phi, Theta, Psi, TheZoom)

# The paintbrush:
TheDrawer.paintbrush.color = (0, 0, 0)
TheDrawer.paintbrush.lineHalfWidth = 0.007 # (The halo half width * the length unit) is the
# number of pixels in the half width of the halo.
TheDrawer.brush3D.haloHalfWidth = 0.015 # (The fringe width * the length unit) is the
# number of pixels in the fringe width of the halo.
TheDrawer.brush3D.haloDepth = 1.0*TheDrawer.brush3D.haloHalfWidth
TheDrawer.brush3D.whiteningMax = 2.0
TheDrawer.brush3D.saturation = 0
TheDrawer.brush3D.amplification = 1.5

# The lattice
width = 3
depth = width
height = width
TheSegmentNumberOfPoints = 3
TheCell = TheDiamondCell(1/width)
TheLattice = TheCell.lattice(width, depth, height, TheSegmentNumberOfPoints)
TheLatticeCenter = TheCell.X.times(width).plus(TheCell.Y.times(depth)).plus(TheCell.Z.times(height)).times(0.5)
TheLattice = TheLattice.minus(TheLatticeCenter)

# The animation:
TheNumberOfImages = 1100
Theta = 90
for i in range(TheNumberOfImages):
    Phi = i*180/TheNumberOfImages
    TheDrawer.choosesApointOfView(TheObjectCenter, TheDistance, Phi, Theta, Psi, TheZoom)
    print("Time:", process_time(), "The drawer draws the image", i)
    TheDrawer.takesAnewCanvas(TheWidth, TheHeight, TheLengthUnit, TheCanvasStyle, TheCanvasColor)
    TheDrawer.draws3Dlines(TheLattice)
    TheDrawer.givesApainting("Lattice/diamond/im" + str(1000+i) + ".png")

print("Time:", process_time(), "Good bye")