def pnt4D(self, ut): "Evaluate parametric point[s] and return 4D homogeneous coordinates" ut = np.asarray(ut, np.float) if np.any(ut < 0.) or np.any(ut > 1.): raise NURBSError, 'NURBS curve parameter out of range [0,1]' return bspeval(self.degree, self.cntrl, self.uknots, ut)
def pnt4D(self, ut, vt=None): """Evaluate parametric point[s] and return 4D homogeneous coordinates. If only ut is given then we will evaluate at scattered points. ut(0,:) represents the u direction. ut(1,:) represents the v direction. If both parameters are given then we will evaluate over a [u,v] grid.""" ut = numerix.asarray(ut, numerix.Float) if numerix.any(ut < 0.) or numerix.any(ut > 1.): raise NURBSError, 'NURBS curve parameter out of range [0,1]' if vt: #FIX! # Evaluate over a [u,v] grid vt = numerix.asarray(vt, numerix.Float) if numerix.any(vt < 0.) or numerix.any(vt > 1.): raise NURBSError, 'NURBS curve parameter out of range [0,1]' val = numerix.resize( self.cntrl, (4 * self.cntrl.shape[1], self.cntrl.shape[2])) val = bspeval(self.degree[1], val, self.vknots, vt) val = numerix.resize(val, (4, self.cntrl.shape[1], vt.shape[0])) val = numerix.transpose(val, (0, 2, 1)) val = numerix.resize(self.cntrl, (4 * vt.shape[0], self.cntrl.shape[1])) val = bspeval(self.degree[0], val, self.uknots, ut) val = numerix.resize(val, (4, vt.shape[0], ut.shape[0])) return numerix.transpose(val, (0, 2, 1)) # Evaluate at scattered points nt = ut.shape[1] uval = numerix.resize(self.cntrl, (4 * self.cntrl.shape[1], self.cntrl.shape[2])) uval = bspeval(self.degree[1], uval, self.vknots, ut[1, :]) uval = numerix.resize(uval, (4, self.cntrl.shape[1], nt)) val = numerix.zeros((4, nt), numerix.Float) for v in range(nt): val[:, v] = bspeval( self.degree[0], numerix.resize(uval[:, :, v], (4, self.cntrl.shape[1])), self.uknots, (ut[0, v], ))[:, 0] return val
def pnt4D(self, ut, vt = None): """Evaluate parametric point[s] and return 4D homogeneous coordinates. If only ut is given then we will evaluate at scattered points. ut(0,:) represents the u direction. ut(1,:) represents the v direction. If both parameters are given then we will evaluate over a [u,v] grid.""" ut = np.asarray(ut, np.float) # if np.less(ut, 0.) or np.greater(ut, 1.): # raise NURBSError, 'NURBS curve parameter out of range [0,1]' if vt != None: # Evaluate over a [u,v] grid vt = np.asarray(vt, np.float) # if np.less(vt, 0.) or np.greater(vt, 1.): # raise NURBSError, 'NURBS curve parameter out of range [0,1]' val = np.resize(self.cntrl,(4*self.cntrl.shape[1],self.cntrl.shape[2])) val = bspeval(self.degree[1], val, self.vknots, vt) val = np.resize(val,(4, self.cntrl.shape[1], vt.shape[0])) val = np.transpose(val,(0,2,1)) val = np.resize(self.cntrl,(4*vt.shape[0],self.cntrl.shape[1])) val = bspeval(self.degree[0], val, self.uknots, ut) val = np.resize(val,(4, vt.shape[0], ut.shape[0])) return np.transpose(val,(0,2,1)) # Evaluate at scattered points nt = ut.shape[1] uval = np.resize(self.cntrl,(4*self.cntrl.shape[1],self.cntrl.shape[2])) uval = bspeval(self.degree[1],uval,self.vknots,ut[1,:]) uval = np.resize(uval,(4, self.cntrl.shape[1], nt)) val = np.zeros((4,nt), np.float) for v in range(nt): val[:,v] = bspeval(self.degree[0],np.resize(uval[:,:,v],(4,self.cntrl.shape[1])), self.uknots, (ut[0,v],))[:,0] return val