コード例 #1
0
 def test_spherical(self, theta, phi):
     st = np.sin(theta)
     ct = np.cos(theta)
     v = geo.spherical_direction(st, ct, phi)
     theta_ret = geo.spherical_theta(v)
     phi_ret = geo.spherical_phi(v)
     assert_almost_eq(theta, theta_ret)
     assert_almost_eq(phi, phi_ret)
コード例 #2
0
	def pdf(self, p: 'geo.Point', w: 'geo.Vector') -> FLOAT:
		wi = self.w2l(w)
		theta = geo.spherical_theta(wi)
		phi = geo.spherical_phi(wi)
		st = np.sin(theta)
		if st == 0.:
			return 0.
		return self.dist.pdf(phi * INV_2PI, theta * INV_PI / 
				(2. * PI * PI * st))
コード例 #3
0
	def sample(self, u1: FLOAT, u2: FLOAT) -> ['geo.Point', 'geo.Normal']:
		"""
		account for partial sphere
		"""
		from pytracer.montecarlo import uniform_sample_sphere
		v = uniform_sample_sphere(u1, u2)

		phi = geo.spherical_theta(v) * self.phiMax * INV_2PI
		theta = self.thetaMin + geo.spherical_theta(v) * (self.thetaMax - self.thetaMin)

		v = geo.spherical_direction(np.sin(theta), np.cos(theta), phi) * self.radius
		v.z = self.zmin + v.z * (self.zmax - self.zmin)

		p = geo.Point.from_arr(v)
		Ns = geo.normalize(self.o2w(geo.Normal(p.x, p.y, p.z)))
		if self.ro:
			Ns *= -1.
		return [self.o2w(p), Ns]
コード例 #4
0
    def __sphere(self, p: 'geo.Point') -> [FLOAT]:
        """
		Spherical Mapping for single
		point. Returns list
		[s, t].
		"""
        v = geo.normalize(self.w2t(p) - geo.Point(0., 0., 0.))
        theta = geo.spherical_theta(v)
        phi = geo.spherical_phi(v)
        return [theta * INV_PI, phi * INV_2PI]
コード例 #5
0
	def __scale(self, w: 'geo.Vector') -> 'Spectrum':
		"""
		__scale()

		Utility method to scale
		the amount of light projected
		in the given direction. Assume
		the scale texture is encoded
		using spherical coordinates.
		"""
		if self.MIPMap is None:
			return Spectrum(1.)

		wp = geo.normalize(self.w2l(w))
		wp.z, wp.y = wp.y, wp.z
		theta = geo.spherical_theta(wp)
		phi = geo.spherical_phi(wp)
		s = phi * INV_2PI
		t = theta * INV_PI

		return Spectrum(self.projMap.look_up([s, t]), SpectrumType.ILLUMINANT)
コード例 #6
0
	def le(self, rd: 'geo.RayDifferential') -> 'Spectrum':
		wh = geo.normalize(self.w2l(rd.d))
		s = geo.spherical_phi(wh) * INV_2PI
		t = geo.spherical_theta(wh) * INV_PI
		return Spectrum.from_rgb(self.radMap.look_up(s, t), SpectrumType.ILLUMINANT)