def compute_sub_window(self, bucket_index: int, bucket_order_info: BucketOrderInfo)->BucketExtend: xo = bucket_index % bucket_order_info.width yo = bucket_index // bucket_order_info.height tx0 = float(xo) / float(bucket_order_info.width) ty0 = float(yo) / float(bucket_order_info.height) tx1 = float(xo + 1) / float(bucket_order_info.width) ty1 = float(yo + 1) / float(bucket_order_info.height) start_x = int(math.floor(get_lerp(self.bucket_extend.start_x, self.bucket_extend.end_x, tx0))) start_y = int(math.floor(get_lerp(self.bucket_extend.start_y, self.bucket_extend.end_y, ty0))) end_x = int(math.floor(get_lerp(self.bucket_extend.start_x, self.bucket_extend.end_x, tx1))) end_y = int(math.floor(get_lerp(self.bucket_extend.start_y, self.bucket_extend.end_y, ty1))) return BucketExtend(start_x, start_y, end_x, end_y)
def UniformSampleCone2(u: (float, float), costhetamax: float, x: Vector3d, y: Vector3d, z: Vector3d) -> float: costheta = get_lerp(costhetamax, 1.0, u[0]) sintheta = math.sqrt(1.0 - costheta * costheta) phi = u[1] * 2.0 * CONST_PI return x * math.cos(phi) * sintheta + y * math.sin(phi) * sintheta + z * costheta