<commit_before>#include "linalg/vector.h"
#include "linalg/point.h"
#include "geometry/differential_geometry.h"
#include "linalg/ray.h"

RayDifferential RayDifferential::reflect(const DifferentialGeometry &dg) const {
	Vector n{dg.normal.normalized()};
	Vector dir = d - 2 * n.dot(d) * n;
	RayDifferential refl{dg.point, dir.normalized(), *this, 0.001};
	refl.rx = Ray{refl.o, refl.d, *this, 0.001};
	refl.ry = Ray{refl.o, refl.d, *this, 0.001};
	if (has_differentials()){
		refl.rx.o = refl.o + dg.dp_dx;
		refl.ry.o = refl.o + dg.dp_dy;
		auto dn_dx = Vector{dg.dn_du * dg.du_dx + dg.dn_dv * dg.dv_dx};
		auto dn_dy = Vector{dg.dn_du * dg.du_dy + dg.dn_dv * dg.dv_dy};
		auto do_dx = -rx.d - d;
		auto do_dy = -ry.d - d;
		float ddn_dx = do_dx.dot(n) + d.dot(dn_dx);
		float ddn_dy = do_dy.dot(n) + d.dot(dn_dy);
		refl.rx.d = refl.d - do_dx + 2 * Vector{d.dot(n) * dn_dx + ddn_dx * n};
		refl.ry.d = refl.d - do_dy + 2 * Vector{d.dot(n) * dn_dy + ddn_dy * n};
		std::cout << "Reflected RayDifferential = " << refl << "\n\n";
	}
	return refl;
}
<commit_msg>Submit prj6 without debugging code<commit_after>#include "linalg/vector.h"
#include "linalg/point.h"
#include "geometry/differential_geometry.h"
#include "linalg/ray.h"

RayDifferential RayDifferential::reflect(const DifferentialGeometry &dg) const {
	Vector n{dg.normal.normalized()};
	Vector dir = d - 2 * n.dot(d) * n;
	RayDifferential refl{dg.point, dir.normalized(), *this, 0.001};
	refl.rx = Ray{refl.o, refl.d, *this, 0.001};
	refl.ry = Ray{refl.o, refl.d, *this, 0.001};
	if (has_differentials()){
		refl.rx.o = refl.o + dg.dp_dx;
		refl.ry.o = refl.o + dg.dp_dy;
		auto dn_dx = Vector{dg.dn_du * dg.du_dx + dg.dn_dv * dg.dv_dx};
		auto dn_dy = Vector{dg.dn_du * dg.du_dy + dg.dn_dv * dg.dv_dy};
		auto do_dx = -rx.d - d;
		auto do_dy = -ry.d - d;
		float ddn_dx = do_dx.dot(n) + d.dot(dn_dx);
		float ddn_dy = do_dy.dot(n) + d.dot(dn_dy);
		refl.rx.d = refl.d - do_dx + 2 * Vector{d.dot(n) * dn_dx + ddn_dx * n};
		refl.ry.d = refl.d - do_dy + 2 * Vector{d.dot(n) * dn_dy + ddn_dy * n};
		//std::cout << "Reflected RayDifferential = " << refl << "\n\n";
	}
	return refl;
}

{'fraction_non_alphanumeric': 0.1877627276973377, 'fraction_numerical': 0.014479215319943952, 'mean_word_length': 3.490566037735849, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6770755', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1013, 'n_words': 194}