add buildFromFunction method in Curve class