Hello!
I just returned back to programming in Python in Grasshopper! And I am working on a new project: the Koch Curve.
However, I can’t seem to solve this problem: moving the midpoint of a curve perpendicularly (the point is supposed to be moved in 2-dimensional space).

The solution I came up with, which, unfortunately, doesn’t deliver my wished result is:
import rhinoscriptsyntax as rs
from math import sqrt
length = rs.CurveLength(input_crv)
distance = length/3
midpoint = rs.CurveMidPoint(input_crv)
distance_to_move = distance * sqrt(3)/2
x = distance_to_move / rs.CurveLength(input_crv)
endpoint = rs.CurveEndPoint(input_crv)
vector1 = rs.VectorCreate(midpoint, (0,0,0))
vector2 = rs.VectorCreate((0, x, 0), midpoint)
vector3 = rs.VectorCreate((0, 1, 0), midpoint)
product = rs.VectorCrossProduct(vector1, vector2)
vector_move = rs.VectorCrossProduct(product, vector3)
top_point = midpoint + vector_move
a = top_point
midpoint = midpoint
This makes the most sense for me mathematically, but I also just started learning and looking at vectors quite recently, so I am open to any additional information or guidance you might provide me with!
moving_point_perpendicularly_to_curve.gh (7.5 KB)
Thanks in advance,
Michalina
