Esempio n. 1
0
    def evaluate_at(self, u):

        # save local to avoid looking up twice or more
        knots = self.knots
        deg = self.deg

        # see "The NURBS Book" 2nd edition: algorithm A2.1 and A2.2
        index = cfdn.get_index(u, deg, knots)
        basis_funs = np.empty((deg + 1, 1), dtype=np.double)
        cfdn.calc_basis_funs(index, u, deg, knots, basis_funs[:, 0])

        # calc homogeneous point
        lb, ub = index - deg, index + 1
        return np.sum(self.ctrl_pnts[lb:ub] * basis_funs, 0)
Esempio n. 2
0
    def evaluate_at(self, u):

        # save local to avoid looking up twice or more
        knots = self.knots
        deg = self.deg

        # see "The NURBS Book" 2nd edition: algorithm A2.1 and A2.2
        index = cfdn.get_index(u, deg, knots)
        basis_funs = np.empty((deg + 1, 1), dtype=np.double)
        cfdn.calc_basis_funs(index, u, deg, knots, basis_funs[:, 0])

        # calc homogeneous point
        lb, ub = index - deg, index + 1
        return np.sum(self.ctrl_pnts[lb:ub] * basis_funs, 0)
Esempio n. 3
0
    def evaluate_at(self, u, v):

        # save local to avoid looking up twice or more
        knots_u, knots_v = self.knots_u, self.knots_v
        deg_u, deg_v = self.deg_u, self.deg_v

        # low level nurbs function written in cython
        index_u = cfdn.get_index(u, deg_u, knots_u)
        basis_funs_u = np.empty((deg_u + 1, 1, 1), dtype=np.double)
        cfdn.calc_basis_funs(index_u, u, deg_u, knots_u, basis_funs_u[:, 0, 0])

        # low level nurbs function written in cython
        index_v = cfdn.get_index(v, deg_v, knots_v)
        basis_funs_v = np.empty((deg_v + 1, 1), dtype=np.double)
        cfdn.calc_basis_funs(index_v, v, deg_v, knots_v, basis_funs_v[:, 0])

        # calc homogeneous point
        lb_u, ub_u = index_u - deg_u, index_u + 1
        lb_v, ub_v = index_v - deg_v, index_v + 1
        tmp = np.sum(self.ctrl_pnts[lb_u:ub_u, lb_v:ub_v] * basis_funs_u, 0)
        return np.sum(tmp * basis_funs_v, 0)
Esempio n. 4
0
    def evaluate_at(self, u, v):

        # save local to avoid looking up twice or more
        knots_u, knots_v = self.knots_u, self.knots_v
        deg_u, deg_v = self.deg_u, self.deg_v

        # low level nurbs function written in cython
        index_u = cfdn.get_index(u, deg_u, knots_u)
        basis_funs_u = np.empty((deg_u + 1, 1, 1), dtype=np.double)
        cfdn.calc_basis_funs(index_u, u, deg_u, knots_u, basis_funs_u[:, 0, 0])

        # low level nurbs function written in cython
        index_v = cfdn.get_index(v, deg_v, knots_v)
        basis_funs_v = np.empty((deg_v + 1, 1), dtype=np.double)
        cfdn.calc_basis_funs(index_v, v, deg_v, knots_v, basis_funs_v[:, 0])

        # calc homogeneous point
        lb_u, ub_u = index_u - deg_u, index_u + 1
        lb_v, ub_v = index_v - deg_v, index_v + 1
        tmp = np.sum(self.ctrl_pnts[lb_u:ub_u, lb_v:ub_v] * basis_funs_u, 0)
        return np.sum(tmp * basis_funs_v, 0)