Greeting,
I want to generate a list of y values from a curve by give the x. This is what I have gotten. Is there a node to achieve it or a python script would help as well.
Thank you for the help.
Greeting,
I want to generate a list of y values from a curve by give the x. This is what I have gotten. Is there a node to achieve it or a python script would help as well.
Thank you for the help.
If you meant to attach an image it did not show up. Try again and we’ll see where you’re at.
There are two basic ways to go about this:
Assuming the start of your curve is (0,0), you can use Curve.PointAtParameter to get a point located on your curve at a specific parameter location. Keep in mind a parameter in this context is a relative value between 0 and 1, so you will have to do some arithmetic to move between global coordinates and relative parameter, but the result will be a point in space that you can pull coordinate values from.

an alternative with scipy
Here is an example of interpolating a point from an abacus curve.
import sys
import clr
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry as DS
from Autodesk.DesignScript.Geometry import *
import scipy
from scipy.interpolate import interp1d
import numpy as np
curve = IN[0]
x_new = IN[1]
pts = [curve.PointAtParameter(i) for i in np.linspace(0, 1, 30)]
data = [[float(p.X), float(p.Y)] for p in pts]
x, y = [i for i in zip(*data)]
f_cubic = interp1d(x, y, kind='cubic', fill_value="extrapolate")
#
y_interpolate = f_cubic(x_new)
OUT = DS.Point.ByCoordinates(x_new, float(y_interpolate), 0)
Using planes is a good way to work with the global axes without having to convert anything relative to the curve’s geometry. Nice.