def collision_detection(self, obj): if isinstance(obj, Object.Bullet): pot = [ self.position[0], self.position[1] - self.earth, self.position[2] ] after_bullet = obj.position before_bullet = obj.back() before_to_after = util.Vec(after_bullet) - util.Vec(before_bullet) pot_to_before = util.Vec(before_bullet) - util.Vec(pot) pot_to_after = util.Vec(after_bullet) - util.Vec(pot) if util.dot(before_to_after, -1 * pot_to_before) < 0: if util.norm(pot_to_before) < self.radius: return True else: return False elif util.dot(before_to_after, pot_to_after) < 0: if util.norm(pot_to_after) < self.radius: return True else: return False else: if util.norm(util.cross3d(before_to_after, pot_to_before) ) / util.norm(before_to_after) < self.radius: return True else: return False
def set_corrector_params(self, step_size, predictor_step): # alpha_t = np.min((step_size.alpha_p,step_size.alpha_d)) if step_size.same_step else step_size.alpha_t # alpha_k = np.min((step_size.alpha_p,step_size.alpha_d)) if step_size.same_step else step_size.alpha_k s1 = util.dot( (self._curr_pt.x + step_size.alpha_p * predictor_step.dx), self._curr_pt.s + step_size.alpha_d * predictor_step.ds) s2 = (self._curr_pt.tau + step_size.alpha_t * predictor_step.dtau) * ( self._curr_pt.kappa + step_size.alpha_k * predictor_step.dkappa) mu_a = s1 + s2 mu_k = util.dot( self._curr_pt.x, self._curr_pt.s) + self._curr_pt.tau * self._curr_pt.kappa # Calculate the Gamma and Eta parameters if mu_a / mu_k <= 0.01: self.gamma = math.pow(mu_a / mu_k, 2) else: self.gamma = np.min( [0.1, np.max([math.pow(mu_a / mu_k, 3), 0.0001])]) self.eta = 1 - self.gamma
def check_linop_adjoint(self, A): with tf.name_scope('check_linop_adjoint'): x = randn(A.ishape, A.dtype.as_numpy_dtype) y = randn(A.oshape, A.dtype.as_numpy_dtype) self.assertAllClose(util.dot(A(x), y).eval(), util.dot(x, A.H(y)).eval(), atol=1e-5, rtol=1e-5)
def oddOneOut1(title1, title2, title3, factor=1, threshold=0, weight=1, smooth=1, returntype=collections.Counter): namelist = [title1, title2, title3] cmp1 = getRelativeCount(namelist[0], namelist, factor, threshold, weight, smooth, returntype) cmp2 = getRelativeCount(namelist[1], namelist, factor, threshold, weight, smooth, returntype) cmp3 = getRelativeCount(namelist[2], namelist, factor, threshold, weight, smooth, returntype) common12 = dot(cmp1,cmp2) common13 = dot(cmp1,cmp3) common23 = dot(cmp2,cmp3) print title1, "has odd factor of", common23 print title2, "has odd factor of", common13 print title3, "has odd factor of", common12
def getOutput(self, inputs): a_1 = [[ util.sigmoid(x) for x in util.add(util.dot(inputs, self.ihWeights), self.ihBias)[0] ]] #a_2 = [[util.sigmoid(x) for x in util.add(util.dot(a_1, self.hhWeights), self.hhBias)[0]]] # uncomment and fix a_3 for 2 hidden layers a_3 = [[ util.sigmoid(x) for x in util.add(util.dot(a_1, self.hoWeights), self.hoBias)[0] ]] return a_3[0]
def calculate_tau_step(self, sol1, sol2): num = self._curr_pt.tau * self._r_g + self._r_tk + self._curr_pt.tau * util.dot( self._LP.c, sol2.u) - self._curr_pt.tau * util.dot( self._LP.b, sol2.v) den = self._curr_pt.kappa - self._curr_pt.tau * util.dot( self._LP.c, sol1.u) + self._curr_pt.tau * util.dot( self._LP.b, sol1.v) d_tau = num / den self.dtau = d_tau
def similarity(self, other): if type(other) is not CPURecord: return 0.1 if other == self: return 1.0 same_caps = 0 for cap in self.capabilities: if cap in other.capabilities: same_caps +=1 m_vec = map(float, [self.numCores, self.cacheSize, len(self.capabilities)]) o_vec = map(float, [other.numCores, other.cacheSize, same_caps]) return util.dot(m_vec, o_vec)/util.dot(m_vec, m_vec)
def intersect(self, o, d): r = self.radius - 0.001 to = util.sub(o, self.center) b = util.dot(to, d) c = util.dot(to, to) - r * r d = b * b - c if d > 0: d = d ** 0.5 t1 = -b - d if t1 > 0: return t1 t2 = -b + d if t2 > 0: return t2 return None
def get_legendre_approximation(self, n: int = 5, verbose: bool = False): approx_borders = self.fs.get_orthogonality_borders() self._approx = function_rescale( self._approx, *self.borders, *approx_borders) c = np.array([dot(*approx_borders, self._approx, self.fs.get_function(i)) * (2 * i + 1) / 2 for i in range(n+1)]) self._legendre = lambda x: np.dot(c, np.array( [self.fs.get_function(i)(x) for i in range(n+1)])) if verbose: print("Continuous delta(integral): ", end='') self._delta(approx_borders) print("Continuous delta(||f||^2 - sum(c_i^2*||phi_i||^2)): ", end='') self._delta_discrete(c, approx_borders) plot_approximation( *approx_borders, "Legendre approximation on [-1,1]", self._approx, self._legendre) self._approx = function_rescale( self._approx, *approx_borders, *self.borders) self._legendre = function_rescale( self._legendre, *approx_borders, *self.borders) if verbose: print("Continuous delta(integral): ", end="") self._delta(self.borders) return self._legendre
def tubo(p1, p2, escala = 0.01, escalaVertice = 2.0, mat = None, extremos = False): sep = SoSeparator() if extremos: sep.addChild(esfera(p1, escala*escalaVertice)) sep.addChild(esfera(p2, escala*escalaVertice)) tr1 = SoTransform() tr2 = SoTransform() if mat == None: mat = SoMaterial() mat.ambientColor.setValue(.0, .0, .0) mat.diffuseColor.setValue(.4, .4, .4) mat.specularColor.setValue(.8, .8, .8) mat.shininess = .1 cil = envuelve(SoCylinder()) cil.setName("segmento") sep.addChild(tr2) sep.addChild(tr1) sep.addChild(mat) sep.addChild(cil) vec = resta(p2, p1) t = norma(vec) tr1.translation = (0, t/2.0, 0) cil[0].radius = escala cil[0].height = t tr2.translation = p1 ejeRot = cross3((0, t, 0), vec) ang = acos(dot((0, t, 0), vec)/t**2) if norma(ejeRot) < .0001: ## son paralelos, así que el prod. cruz da el vector nulo. ## como el vector base es de la forma (0,t,0), entonces ## (1,0,0) es ortogonal a el, y puede proceder la rotación ejeRot = (1, 0, 0) tr2.rotation.setValue(SbVec3f(ejeRot), ang) return sep
def tubo(p1, p2, escala=0.01, escalaVertice=2.0, mat=None, extremos=False): sep = SoSeparator() if extremos: sep.addChild(esfera(p1, escala * escalaVertice)) sep.addChild(esfera(p2, escala * escalaVertice)) tr1 = SoTransform() tr2 = SoTransform() if mat == None: mat = SoMaterial() mat.ambientColor.setValue(.0, .0, .0) mat.diffuseColor.setValue(.4, .4, .4) mat.specularColor.setValue(.8, .8, .8) mat.shininess = .1 cil = envuelve(SoCylinder()) cil.setName("segmento") sep.addChild(tr2) sep.addChild(tr1) sep.addChild(mat) sep.addChild(cil) vec = resta(p2, p1) t = norma(vec) tr1.translation = (0, t / 2.0, 0) cil[0].radius = escala cil[0].height = t tr2.translation = p1 ejeRot = cross3((0, t, 0), vec) ang = acos(dot((0, t, 0), vec) / t**2) if norma(ejeRot) < .0001: ## son paralelos, así que el prod. cruz da el vector nulo. ## como el vector base es de la forma (0,t,0), entonces ## (1,0,0) es ortogonal a el, y puede proceder la rotación ejeRot = (1, 0, 0) tr2.rotation.setValue(SbVec3f(ejeRot), ang) return sep
def test_random_positions_lim_fraction(self): R = uniform(0,1) N = uniform(0,1000) x = random_positions(R,N) r = dot(x,x) assert_array_less(r,R**2)
def getOddity2(namelist, threshold=0): cmp12 = normalizedCompare(namelist[1], namelist[0]) cmp13 = normalizedCompare(namelist[2], namelist[0]) linfilter(cmp12, threshold) linfilter(cmp13, threshold) # print cmp12 # print cmp13 return dot(cmp12, cmp13)
def test_spherical_lim(self): R = uniform(0,10) N = uniform(0,1000) x = spherical(R,N) r = dot(x,x) assert_allclose(R**2,r)
def test_dot(self): for dtype in ['float32', 'complex64']: shape = [3, 4] x1 = randn(shape, dtype) x2 = randn(shape, dtype) with self.test_session(): self.assertAllClose( np.vdot(x1, x2).real, util.dot(x1, x2).eval())
def chara_and_bullet(chara,bullet): if chara.states[0] == bullet.states[0]: return False if not isinstance(chara,gameobject.character): return False pot = chara.position - (0,chara.earth,0) after_bullet = bullet.position before_bullet = bullet.before_position before_to_after = after_bullet - util.Vec(before_bullet) pot_to_before = util.Vec(before_bullet) - util.Vec(pot) pot_to_after = util.Vec(after_bullet) - util.Vec(pot) if util.dot(before_to_after,-1 * pot_to_before) < 0: return abs(pot_to_before) < chara.radius elif util.dot(before_to_after,pot_to_after) < 0: return abs(pot_to_after) < chara.radius else: return abs(util.cross3d(before_to_after,pot_to_before)) / abs(before_to_after) < chara.radius
def test_dot_list(self): n = 10 a = rand(n,3) b = rand(n,3) np = zeros(n) for i in xrange(n): np[i] = npdot(a[i],b[i]) assert_allclose(np,dot(a,b))
def is_optimal(LP, curr_pt, start_pt, tol1, tol2, tol3): # Check the duality gap cond1 = np.true_divide( np.absolute(util.dot(LP.c, curr_pt.x) - util.dot(LP.b, curr_pt.y)), curr_pt.tau + np.absolute(util.dot(LP.b, curr_pt.y))) < tol1 # Check primal infeasibility rp = curr_pt.tau * LP.b - LP.A.dot(curr_pt.x) cond2 = np.true_divide(np.linalg.norm(rp), curr_pt.tau + np.linalg.norm(curr_pt.x)) < tol1 # Check dual infeasibility rd = curr_pt.tau * LP.c - LP.A.transpose().dot(curr_pt.y) - curr_pt.s cond3 = np.true_divide(np.linalg.norm(rd), curr_pt.tau + np.linalg.norm(curr_pt.s)) < tol1 # Check for infeasibility mu_k = np.true_divide( util.dot(curr_pt.x, curr_pt.s) + curr_pt.tau * curr_pt.kappa, LP.shape[1] + 1) mu_0 = np.true_divide( util.dot(start_pt.x, start_pt.s) + start_pt.tau * start_pt.kappa, LP.shape[1] + 1) cond4 = np.true_divide(mu_k, mu_0) < tol2 cond5 = np.true_divide(curr_pt.tau * start_pt.kappa, curr_pt.kappa * start_pt.tau) < tol3 optimal = cond1 and cond2 and cond3 infeasible = cond4 and cond5 converge = optimal or infeasible return {"converge": converge, "optimal": optimal, "infeasible": infeasible}
def test_dot_matrix(self): n = 10 a = rand(n,n,3) b = rand(n,n,3) np = zeros((n,n)) for i in xrange(n): for j in xrange(n): np[i,j] = npdot(a[i,j],b[i,j]) assert_allclose(np,dot(a,b))
def test_plummer_quartiles(self): r = dot(self.x,self.x) r = sort(r) r_1 = sqrt(r[round(self.N/4) - 1]) r_2 = sqrt(r[round(self.N/2) - 1]) r_3 = sqrt(r[round(3*self.N/4) - 1]) r_4 = sqrt(r[self.N]) # print r_1,r_2,r_3 assert_allclose(0.4778,r_1,self.rtol,self.atol) assert_allclose(0.7686,r_2,self.rtol,self.atol) assert_allclose(1.2811,r_3,self.rtol,self.atol)
def ase(n,f_true): n.find_r() n.find_a() # use function f_true # to find true force true = f_true(n) mase = n.a - true mase = dot(mase,mase) mase = sum(mase)/n.n return mase
def __init__(self, LP, curr_pt, eta, gamma, residual_step=None): self._LP = LP self._curr_pt = curr_pt # Add checks for the values of eta and gamma self._eta = eta self._gamma = gamma # Residuals at current point self._r_p = self._curr_pt.tau * self._LP.b - self._LP.A.dot( self._curr_pt.x) self._r_d = self._curr_pt.tau * self._LP.c - self._LP.A.transpose( ).dot(self._curr_pt.y) - self._curr_pt.s self._r_g = self._curr_pt.kappa + util.dot( self._LP.c, self._curr_pt.x) - util.dot(self._LP.b, self._curr_pt.y) # complementarity-gap at current point self._mu = np.true_divide( util.dot(self._curr_pt.x, self._curr_pt.s) + self._curr_pt.kappa * self._curr_pt.tau, self._LP.shape[1] + 1) self._r_xs = np.dot( -1 * np.diag(self._curr_pt.x.transpose()[0]), self._curr_pt.s) + self._gamma * self._mu * np.ones( (self._LP.shape[1], 1)) self._r_tk = -1 * self._curr_pt.tau * self._curr_pt.kappa + self._gamma * self._mu # Add the residual term self._r_xs = self._r_xs - np.dot( np.diag(residual_step.dx.transpose()[0]), residual_step.ds) if residual_step is not None else self._r_xs self._r_tk = self._r_tk - residual_step.dtau * residual_step.dkappa if residual_step is not None else self._r_tk # This functions calculates all the steps and assign them to class variables self.compute_step()
def collision_detection(self,obj): if isinstance(obj,Object.Bullet): pot = [self.position[0], self.position[1] - self.earth, self.position[2]] after_bullet = obj.position before_bullet = obj.back() before_to_after = util.Vec(after_bullet) - util.Vec(before_bullet) pot_to_before = util.Vec(before_bullet) - util.Vec(pot) pot_to_after = util.Vec(after_bullet) - util.Vec(pot) if util.dot(before_to_after,-1 * pot_to_before) < 0: if util.norm(pot_to_before) < self.radius: return True else: return False elif util.dot(before_to_after,pot_to_after) < 0: if util.norm(pot_to_after) < self.radius: return True else: return False else: if util.norm(util.cross3d(before_to_after,pot_to_before)) / util.norm(before_to_after) < self.radius: return True else: return False
def spaceConversion_HPE_to_XYZ(self, LMS_prime, M_H_inv): XYZ = ut.dot(M=M_H_inv, img=LMS_prime) return XYZ
def Aab_to_HPE(Aab, N_bb): Aab[:, :, 0] /= N_bb Aab[:, :, 0] += 0.305 HPE = ut.dot(M=M_HPE_to_A_xab_inv, img=Aab) return HPE
def LMS_a_prime_inv(self, A, a, b, N_bb, M_LMS_prime_to_A_xab_inv): x = A / N_bb + 0.305 xab = np.stack([x, a, b], axis=-1) result = ut.dot(M=M_LMS_prime_to_A_xab_inv, img=xab) return result
def bullet_and_wall(bullet,wall): bullet_xzposi = util.Vec(bullet.position[0],bullet.position[2]) wall_xzbase = [util.Vec(x[0],x[2]) for x in [wall.base_point1,wall.base_point2]] wall_xznormal = util.Vec(wall.normal[0],wall.normal[2]) point1to2 = wall_xzbase[1] - wall_xzbase[0] point1tobullet = bullet_xzposi - wall_xzbase[0] point2tobullet = bullet_xzposi - wall_xzbase[1] point1tobeforebullet = util.Vec(bullet.before_position[0],bullet.before_position[2]) - wall_xzbase[0] return bullet.position[1] >= wall.base_point1[1] -1.2 and bullet.position[1] <= wall.base_point1[1] + wall.height - 1.2 and util.dot(point1to2,point1tobullet) * util.dot(point1to2,point2tobullet) <= 0 and util.dot(wall_xznormal,point1tobullet) * util.dot(wall_xznormal,point1tobeforebullet) <= 0
def _delta(self, borders): print("||f-Qn||^2 =", dot(*borders, lambda x: self._approx(x) - self._mqa(x), lambda x: self._approx(x) - self._mqa(x)))
def F_true(n): r2 = dot(n.x,n.x) r_unit = n.x/sqrt(r2)[:,newaxis] true = -n.G*M*r_unit*((1 + a2/r2)**(-3./2.))[:,newaxis] return true
def _delta_discrete(self, c, borders): yield_sys = [(c[i] ** 2) * dot(*borders, self._fs.get_function(i), self._fs.get_function(i)) for i in range(len(c))] print("||f-Qn||^2 =", abs(dot(*borders, self._approx, self._approx) - sum(yield_sys)))
def XYZ_to_LMS(XYZ): LMS = ut.dot(M=M_CAT02, img=XYZ) return LMS
print '#','softening','radius','true acceleration','radial acceleration','bias','variance' # do for different values of softening for s in np.arange(0,1+dr,dr): binned_a = [[] for _ in range(len(bins))] binned_x = [[] for _ in range(len(bins))] for _ in xrange(times): x = random_positions(Rv,N) n = N_bodies(m*np.ones(N),x,np.zeros((N,3)),dt=1,softening=s) n.x -= find_barycentre(n) n.find_r() n.find_a() # bin according to radius ind = np.digitize(np.sqrt(dot(n.x,n.x)),bins) for i,bin in enumerate(ind): binned_a[bin-1].append(n.a[i]) binned_x[bin-1].append(n.x[i]) for i,r in enumerate(bins): if not binned_a[i] and not binned_x[i]: continue a = np.array(binned_a[i]) x = np.array(binned_x[i]) # true = -f_true(0.5*(r+dr)) true = -f_true(r) # radial acceleration # r_unit = -x/dot(x,x)[:,np.newaxis] # a_r = dot(a,r_unit) a_r = np.sqrt(dot(a,a)) a_r = np.mean(a_r)
#Set up Matrix and vector of the right hand side from assembleStiffness import assembleSingleLayer A = assembleSingleLayer(basis, space_proj, time_proj) print "matrix set up" from assembleVector import assembleVector B = assembleVector(g, basis, space_proj, time_proj) print "vector set up" #solve the linear system from solve import solveMem sol = solveMem(A,B,Nx,Nt) print "linear system solved" #convergence values) ndof.append(len(sol)) from util import dot norm.append(dot(B,sol)) print cnt cnt += 1 print "nshape", ndof print "norm", norm from calcSol import calcSolIndirect u = calcSolIndirect(space_proj, time_proj, sol, basis) from plotHeatMap import plotSpace plotSpace(lambda x: u(x,1), 20)
def LMS_to_XYZ(LMS): XYZ = ut.dot(M=M_CAT02_inv, img=LMS) return XYZ
def find_r(self): self.r[...] = self.x_c[:,np.newaxis,:]-self.x_c self.r_u[...] = self.r[self.i_u] self.r_norm2_u[...] = dot(self.r_u,self.r_u)
def Cosine_norm(u, v): """Cosine hash metric - Angular distance""" return 1.0 - dot(u, v) / sqrt(dot(u, u) * dot(v, v))
def RGB_linear_to_XYZ_full_backlight(RGB_linear): XYZ = ut.dot(M=M_full_backlight, img=RGB_linear) return XYZ
def HPE_to_XYZ(HPE): XYZ = ut.dot(M=M_H_inv, img=HPE) return XYZ
def hash(self, vec): return int(dot(vec, self.r) > 0)
def XYZ_to_HPE(XYZ): HPE = ut.dot(M=M_H, img=XYZ) return HPE
def is_same_step(self): if (self.alpha_p > self.alpha_d) and (util.dot(self._curr_pt.s,self._step.dx) <= 0) : return False if (self.alpha_p < self.alpha_d) and (util.dot(self._curr_pt.x,self._step.ds) <= 0): return False return True
from util import dot from numpy import array a = array([1,2]) b = array([[1,2,],[3,4]]) c = array([1,2]) print dot(a,dot(b,c)) print dot(a,b,c) print dot(dot(a,b),c) print dot(b,c)
def _make_system(self, a0, b0, n): v = np.array([dot(a0, b0, self._approx, self._fs.get_function(i)) for i in range(n+1)]) matrix = np.array([[dot(a0, b0, self._fs.get_function(k), self._fs.get_function(j)) for j in range(n+1)] for k in range(n+1)]) return matrix, v
def chara_and_wall_ALL(chara,wall): chara_xzposi = util.Vec(chara.position[0],chara.position[2]) wall_xzbase = [util.Vec(x[0],x[2]) for x in [wall.base_point1,wall.base_point2]] wall_xznormal = util.Vec(wall.normal[0],wall.normal[2]) point1to2 = wall_xzbase[1] - wall_xzbase[0] point1tochara = chara_xzposi - wall_xzbase[0] point2tochara = chara_xzposi - wall_xzbase[1] if chara.position[1] + chara.radius * 2 >= wall.base_point1[1] and chara.position[1] < wall.base_point1[1] + wall.height: wall_r_xzbase = [wall_xzbase[0] - point1to2 * chara.radius / abs(point1to2), wall_xzbase[1] + point1to2 * chara.radius / abs(point1to2)] point_r_tochara = [chara_xzposi - x for x in wall_r_xzbase] if util.dot(point1to2,point1tochara) * util.dot(point1to2,point2tochara) <= 0 : if isinstance(chara,gameobject.player): camera_and_wall_ALL(chara,wall) before_chara_xzposi = util.Vec(chara.before_position[0],chara.before_position[2]) point1tochara = [chara_xzposi + chara.radius * wall_xznormal - wall_xzbase[0], chara_xzposi - chara.radius * wall_xznormal - wall_xzbase[0], chara_xzposi - wall_xzbase[0]] point1tobeforechara = [before_chara_xzposi + chara.radius * wall_xznormal - wall_xzbase[0], before_chara_xzposi - chara.radius * wall_xznormal - wall_xzbase[0], before_chara_xzposi - wall_xzbase[0]] if util.dot(wall_xznormal,point1tochara[0]) * util.dot(wall_xznormal,point1tobeforechara[0]) <= 0 or util.dot(wall_xznormal,point1tochara[1]) * util.dot(wall_xznormal,point1tobeforechara[1]) <= 0: distance = sqrt((abs(point1tochara[2])) ** 2 - (util.dot(point1to2,point1tochara[2]) / abs(point1to2)) ** 2) slip = 1.5 if util.dot(wall_xznormal,point1tobeforechara[2]) >= 0: if util.dot(wall_xznormal,point1tochara[2]) >= 0: chara.position += 1.1 * (chara.radius - distance) * wall.normal chara.slip = (chara.radius - distance) * wall.normal * slip else: chara.position += 1.1 * (chara.radius + distance) * wall.normal chara.slip = (chara.radius + distance) * wall.normal * slip else: if util.dot(wall_xznormal,point1tochara[2]) >= 0: chara.position -= 1.1 * (chara.radius + distance) * wall.normal chara.slip = -(chara.radius + distance) * wall.normal * slip else: chara.position -= 1.1 * (chara.radius - distance) * wall.normal chara.slip = -(chara.radius - distance) * wall.normal * slip elif (util.dot(point_r_tochara[0],point1to2) * util.dot(point1to2,point_r_tochara[1]) <= 0 and (abs(point1tochara) <= chara.radius or abs(point2tochara) <= chara.radius)): before_chara_xzposi = util.Vec(chara.before_position[0],chara.before_position[2]) point1tobeforechara = before_chara_xzposi - wall_xzbase[0] distance = sqrt((abs(point1tochara)) ** 2 - (util.dot(point1to2,point1tochara) / abs(point1to2)) ** 2) slip = 0.5 if util.dot(wall_xznormal,point1tobeforechara) >= 0: if util.dot(wall_xznormal,point1tochara) >= 0: chara.position += 1.1 * (chara.radius - distance) * wall.normal chara.slip = (chara.radius - distance) * wall.normal * slip else: chara.position += 1.1 * (chara.radius + distance) * wall.normal chara.slip = (chara.radius + distance) * wall.normal * slip else: if util.dot(wall_xznormal,point1tochara) >= 0: chara.position -= 1.1 * (chara.radius + distance) * wall.normal chara.slip = -(chara.radius + distance) * wall.normal * slip else: chara.position -= 1.1 * (chara.radius - distance) * wall.normal chara.slip = -(chara.radius - distance) * wall.normal * slip
def spaceConversion_LMS_to_XYZ(self, LMS, M_CAT02_inv): XYZ = ut.dot(M=M_CAT02_inv, img=LMS) return XYZ
def camera_and_wall_ALL(chara,wall): wall_to_chara = chara.position - wall.base_point1 wall_to_camera = chara.camera_position - wall.base_point1 if util.dot(wall.normal,wall_to_chara) * util.dot(wall.normal,wall_to_camera) <= 0: wall.draw_cancel = True
def spaceConversion_XYZ_to_HPE(self, XYZ, M_H): LMS_prime = ut.dot(M=M_H, img=XYZ) return LMS_prime
def spaceConversion_HPE_to_Opponent(self, LMS_prime, M_LMS_prime_to_A_xab, N_bb): A_xab = ut.dot(M=M_LMS_prime_to_A_xab, img=LMS_prime) Aab = A_xab Aab[:, :, 0] -= 0.305 Aab[:, :, 0] *= N_bb return Aab
def HPE_to_Aab(HPE, N_bb): Aab = ut.dot(M=M_HPE_to_A_xab, img=HPE) Aab[:, :, 0] -= 0.305 Aab[:, :, 0] *= N_bb return Aab
def hash(self, vec): val = (dot(vec, self.r) + self.b) / self.w return int(val)
def spaceConversion_Opponent_to_HPE(self, Aab, M_LMS_prime_to_A_xab_inv, N_bb): Aab[:, :, 0] /= N_bb Aab[:, :, 0] += 0.305 LMS_prime = ut.dot(M=M_LMS_prime_to_A_xab_inv, img=Aab) return LMS_prime
def XYZ_to_RGB_linear_low_backlight(XYZ): RGB_linear_low_backlight = ut.dot(M=M_low_backlight_inv, img=XYZ) return RGB_linear_low_backlight
def spaceConversion_XYZ_to_LMS(self, XYZ, M_CAT02): LMS = ut.dot(M=M_CAT02, img=XYZ) return LMS