mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 13:01:00 +00:00
3D Hilbert Curve Implemented
This commit is contained in:
parent
87801c2ed8
commit
19a0a72545
1 changed files with 31 additions and 10 deletions
|
@ -423,18 +423,39 @@ class HilbertCurve(SelfSimilarSpaceFillingCurve):
|
|||
|
||||
class HilbertCurve3D(SelfSimilarSpaceFillingCurve):
|
||||
CONFIG = {
|
||||
"offsets" : [
|
||||
LEFT+DOWN+OUT,
|
||||
LEFT+UP+OUT,
|
||||
LEFT+UP+IN,
|
||||
LEFT+DOWN+IN,
|
||||
RIGHT+DOWN+IN,
|
||||
RIGHT+UP+IN,
|
||||
RIGHT+UP+OUT,
|
||||
RIGHT+DOWN+OUT,
|
||||
"offsets" : [
|
||||
RIGHT+DOWN+IN,
|
||||
LEFT+DOWN+IN,
|
||||
LEFT+DOWN+OUT,
|
||||
RIGHT+DOWN+OUT,
|
||||
RIGHT+UP+OUT,
|
||||
LEFT+UP+OUT,
|
||||
LEFT+UP+IN,
|
||||
RIGHT+UP+IN,
|
||||
],
|
||||
"offset_to_rotation_axis" : {}#TODO
|
||||
"offset_to_rotation_axis_and_angle" : {
|
||||
str(RIGHT+DOWN+IN) : (LEFT+UP+OUT , 2*np.pi/3),
|
||||
str(LEFT+DOWN+IN) : (RIGHT+DOWN+IN, 2*np.pi/3),
|
||||
str(LEFT+DOWN+OUT) : (RIGHT+DOWN+IN, 2*np.pi/3),
|
||||
str(RIGHT+DOWN+OUT) : (UP , np.pi ),
|
||||
str(RIGHT+UP+OUT) : (UP , np.pi ),
|
||||
str(LEFT+UP+OUT) : (LEFT+DOWN+OUT, 2*np.pi/3),
|
||||
str(LEFT+UP+IN) : (LEFT+DOWN+OUT, 2*np.pi/3),
|
||||
str(RIGHT+UP+IN) : (RIGHT+UP+IN , 2*np.pi/3),
|
||||
},
|
||||
}
|
||||
# Rewrote transform method to include the rotation angle
|
||||
def transform(self, points, offset):
|
||||
copy = np.array(points)
|
||||
copy = rotate(
|
||||
copy,
|
||||
axis = self.offset_to_rotation_axis_and_angle[str(offset)][0],
|
||||
angle = self.offset_to_rotation_axis_and_angle[str(offset)][1],
|
||||
)
|
||||
copy /= self.scale_factor,
|
||||
copy += offset*self.radius*self.radius_scale_factor
|
||||
return copy
|
||||
|
||||
|
||||
class PeanoCurve(SelfSimilarSpaceFillingCurve):
|
||||
CONFIG = {
|
||||
|
|
Loading…
Add table
Reference in a new issue