STUDIO TAMA

Rhinoceros & Grasshopper Utilities

Home

GH Sample Files

GH Python Tutorials

Rhino Assets

Books

Blog

Plugins

About

Privacy Policy

Terms of Service

Contact

© 2025 STUDIO TAMA

Day 19

編み物のような交差パターン

#wave#weave#pattern#3d#curve#symmetry
編み物のような交差パターン

✅ Inputs

- length: float – 曲線の長さ(X/Y方向)
- amp: float – Z方向の波の振幅
- wave_cycles: float – Sin波の繰り返し数
- res: int – 曲線の分割数(滑らかさ)
- radius: float – Pipeの半径

✅ Outputs

- results: list of Brep – 編み目構造を構成するパイプ群

✅ Code

import Rhino.Geometry as rg
import math

# === 🔧 入力パラメータ例 ===
# length = 2000.0         # 曲線の長さ(X/Y方向)
# amp = 30.0              # Z方向の振幅
# wave_cycles = 10.0      # 波の繰り返し数
# res = 50                # 曲線分割数
# radius = 20.0           # Pipe半径

period = length / wave_cycles
spacing = period / 2
offset_shift = spacing / 2

num_x = int(length // spacing)
num_y = int(length // spacing)

freq = wave_cycles * math.pi * 2 / length

# === 📐 Sin波曲線生成
def create_wave_curve(axis='x', offset=0.0, reverse=False):
    phase = math.pi if reverse else 0.0
    points = []
    for i in range(res + 1):
        t = float(i) / res
        u = t * length
        z = math.sin(u * freq + phase) * amp
        pt = rg.Point3d(u, offset, z) if axis == 'x' else rg.Point3d(offset, u, z)
        points.append(pt)
    return rg.Curve.CreateInterpolatedCurve(points, 3)

# === 🔁 波を複製する共通関数
def generate_wave_family(axis, count, spacing, shift, start_reverse=True):
    curves = []
    for i in range(count):
        offset = i * spacing + shift
        reverse = (i % 2 == 1) if start_reverse else (i % 2 == 0)
        curves.append(create_wave_curve(axis, offset, reverse))
    return curves

# === 🔁 X/Y方向の波を生成
curves = []
curves.extend(generate_wave_family('x', num_y, spacing, offset_shift, start_reverse=True))
curves.extend(generate_wave_family('y', num_x, spacing, offset_shift, start_reverse=False))

# === 🧵 Pipe化
results = []
for c in curves:
    pipes = rg.Brep.CreatePipe(c, radius, False, rg.PipeCapMode.Round, True, 0.001, 0.001)
    if pipes:
        results.extend(pipes)
← Back to Grasshopper Python Tutorials

License & Terms of Use

ItemAllowedDescription
Integration into your projectsYou are free to use the code as part of your scripts or works, whether for personal or commercial purposes.
Code modification & learning useCustomizing the code for your own learning or specific purposes is very welcome.
Sharing on SNS / showcasingNo permission is required to share images or URLs of your works. Please feel free to showcase them!
Redistribution / republishing×Do not publish the code or files in their entirety as content on your own site or elsewhere.
Reselling as materials/programs×Do not sell the content of this site, either as-is or with only minor modifications, for a fee.
Copyright notice / linkOptionalNot required, but including a link to the source would be greatly appreciated.
Day Day 19 - 編み物のような交差パターン | Grasshopper Python 入門チュートリアル | STUDIO TAMA