Exemplo n.º 1
0
    def set_curves(self):
        degree = 2
        num_cp = 2
        CP, U = F.curve_fit2D(self.points, np.ones((len(self.points), 1)),
                              None, None, None, num_cp, degree)

        B_cur = BSpline.Curve()
        B_cur.degree = degree
        B_cur.ctrlpts = CP
        B_cur.knotvector = U
        B_cur.evaluate()
        B_cur.delta = 0.01

        N_cur = convert.bspline_to_nurbs(B_cur)
        # Set evaluation delta
        N_cur.delta = 0.01
        N_cur.evaluate()

        return N_cur, B_cur
Exemplo n.º 2
0
 def test_fitting(self):
     CP, U = F.curve_fit2D(self.points, np.ones((len(self.points), 1)),
                           None, None, None, 2, 2)
     self.assertTrue(isinstance(CP, tuple))
     self.assertTrue(isinstance(U, list))
Exemplo n.º 3
0
#  Plot test function
fig = plt.figure(num=1)
plt.plot(x_samp, y_samp, 'o')  # Nicer plot
plt.plot(np.linspace(0, 1, num=1000), Branin_1d(np.linspace(0, 1, num=1000)))
# plt.show()

'''
Step 2)
Create a B-spline and fit it to the data
'''

degree = 5
n = 5

# Adapt a B-spline to the curve.
CP, U = Fitting.curve_fit2D(Q, np.ones((len(Q), 1)), None, None, None, n, degree)
# Transform to Tupled tuples


# Create a BSpline (NURBS) curve instance
test_c = BSpline.Curve()

# Set up the curve
test_c.degree = degree
test_c.ctrlpts = CP
# test_c.ctrlpts = exchange.import_txt("ex_curve02.cpt")

test_c.knotvector = U
# Auto-generate knot vector
# test_c.knotvector = utilities.generate_knot_vector(test_c.degree, len(test_c.ctrlpts))
# Set evaluation delta