Day 8
(2.5)

折り紙 – 4つの谷折りで立体化

#origami#triangle#transform#3d
折り紙 – 4つの谷折りで立体化のサムネイル

✅ Inputs

  • `size`: float – 折り紙の一辺の長さ
  • `fold_angle_deg`: float – 折り角(谷折りは正の値、単位は度)

✅ Outputs

  • `results`: list of `Brep` – 折られた4枚の面と中央の底面を含む折り紙モデル

✅ Code

import Rhino.Geometry as rg
import math

center = rg.Point3d(size / 2, size / 2, 0)

p0 = rg.Point3d(0, 0, 0)
p1 = rg.Point3d(size, 0, 0)
p2 = rg.Point3d(size, size, 0)
p3 = rg.Point3d(0, size, 0)

base_surface = rg.Brep.CreateFromCornerPoints(p0, p1, p2, p3, 0.001)

triangles = [
    [center, p0, p1],
    [center, p1, p2],
    [center, p2, p3],
    [center, p3, p0]
]

axes = [
    (p0, p1),
    (p1, p2),
    (p2, p3),
    (p3, p0)
]

angle_rad = math.radians(fold_angle_deg)
results = [base_surface]

for tri, (axis_start, axis_end) in zip(triangles, axes):
    axis_dir = rg.Vector3d(axis_end - axis_start)
    rotation = rg.Transform.Rotation(angle_rad, axis_dir, axis_start)

    rotated_pts = [pt if pt == axis_start or pt == axis_end else rg.Point3d(pt) for pt in tri]
    for i, pt in enumerate(rotated_pts):
        if pt != axis_start and pt != axis_end:
            pt.Transform(rotation)
            rotated_pts[i] = pt

    brep = rg.Brep.CreateFromCornerPoints(*rotated_pts, 0.001)
    results.append(brep)