Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def identity(d):
return Frames(zeros(d),Rotation.identity(d))
def __eq__(self,x):
assert isinstance(x,Frames)
return all(self.reals()==x.reals(),axis=-1)
def __mul__(self,x):
if isinstance(x,Frames):
return Frames(self.t+self.r*x.t,self.r*x.r)
return self.t+self.r*x
def from_reals(x):
x = asarray(x)
d = size_to_d[x.shape[-1]]
return x.ravel().view(Frames.dtypes[d]).view(Frames).reshape(x.shape[:-1])
interp = frame_interpolation_2d if f1.d==2 else frame_interpolation_3d
if f1.shape!=f2.shape:
b = broadcast(f1,f2)
new_f = [empty(b.shape,dtype=f1.dtype).view(Frames) for _ in xrange(2)]
new_f[0][:] = f1
new_f[1][:] = f2
f1,f2 = new_f
return interp(f1.ravel(),f2.ravel(),s).reshape(f1.shape)
size_to_d = {4:2,7:3}
def from_reals(x):
x = asarray(x)
d = size_to_d[x.shape[-1]]
return x.ravel().view(Frames.dtypes[d]).view(Frames).reshape(x.shape[:-1])
other_core._set_frame_type(Frames)
def interpolation(f1,f2,s):
interp = frame_interpolation_2d if f1.d==2 else frame_interpolation_3d
if f1.shape!=f2.shape:
b = broadcast(f1,f2)
new_f = [empty(b.shape,dtype=f1.dtype).view(Frames) for _ in xrange(2)]
new_f[0][:] = f1
new_f[1][:] = f2
f1,f2 = new_f
return interp(f1.ravel(),f2.ravel(),s).reshape(f1.shape)
def inverse(self):
ri = self.r.inverse()
return Frames(ri*-self.t,ri)