<commit_before>#pragma once

#include "fwddecl.h"
#include "Matrix.h"
#include "Ray.h"
#include "RayHit.h"

namespace Cruisky{
	namespace RayTracer
	{
		class Transform {
		public:
			Transform(){}
			Transform(Vector3 position, Vector3 rotation = Vector3::ZERO, Vector3 scale = Vector3::ONE){
				if(position != Vector3::ZERO) Translate(position);
				if(rotation != Vector3::ZERO) Rotate(rotation);
				if(scale != Vector3::ONE) Scale(scale);
			}
			~Transform(){}

			const Vector3& GetPosition() const { return position_; }
			const Matrix4x4& GetWorldToLocal() const { return world_local_; }
			const Matrix4x4& GetLocalToWorld() const { return local_world_; }

			Transform& Translate(const Vector3& translation);
			Transform& Rotate(const Vector3& rotation);
			Transform& Rotate(float angle, const Vector3& axis);
			Transform& Scale(const Vector3& scale);
			Transform& LookAt(const Vector3& dir);
			Transform& LookAt(const Vector3& dir, const Vector3& up);
			//Transform& LookAt(const Vector3& pt_eye, const Vector3& pt_target, const Vector3& up);

			inline Transform& Translate(float x, float y, float z){ return Translate(Vector3(x, y, z)); }
			inline Transform& Rotate(float x, float y, float z){ return Rotate(Vector3(x, y, z)); }
			inline Transform& Scale(float x, float y, float z){ return Scale(Vector3(x, y, z)); }

			inline Ray ToWorld(const Ray& ray) const{
				return Ray(
					Matrix4x4::TPoint(local_world_, ray.origin),
					Matrix4x4::TVector(local_world_, ray.dir).Normalize(),
					ray.t_min, ray.t_max);
			}

			inline RayHit ToWorld(const RayHit& hit) const{
				return RayHit(
					Matrix4x4::TPoint(local_world_, hit.point),
					Matrix4x4::TNormal(local_world_, hit.normal).Normalize());
			}

			inline Ray ToLocal(const Ray& ray) const{
				return Ray(
					Matrix4x4::TPoint(world_local_, ray.origin),
					Matrix4x4::TVector(world_local_, ray.dir).Normalize(),
					ray.t_min, ray.t_max);
			}<commit_msg>transform::ToLocal should not normalize the ray<commit_after>#pragma once

#include "fwddecl.h"
#include "Matrix.h"
#include "Ray.h"
#include "RayHit.h"

namespace Cruisky{
	namespace RayTracer
	{
		class Transform {
		public:
			Transform(){}
			Transform(Vector3 position, Vector3 rotation = Vector3::ZERO, Vector3 scale = Vector3::ONE){
				if(position != Vector3::ZERO) Translate(position);
				if(rotation != Vector3::ZERO) Rotate(rotation);
				if(scale != Vector3::ONE) Scale(scale);
			}
			~Transform(){}

			const Vector3& GetPosition() const { return position_; }
			const Matrix4x4& GetWorldToLocal() const { return world_local_; }
			const Matrix4x4& GetLocalToWorld() const { return local_world_; }

			Transform& Translate(const Vector3& translation);
			Transform& Rotate(const Vector3& rotation);
			Transform& Rotate(float angle, const Vector3& axis);
			Transform& Scale(const Vector3& scale);
			Transform& LookAt(const Vector3& dir);
			Transform& LookAt(const Vector3& dir, const Vector3& up);
			//Transform& LookAt(const Vector3& pt_eye, const Vector3& pt_target, const Vector3& up);

			inline Transform& Translate(float x, float y, float z){ return Translate(Vector3(x, y, z)); }
			inline Transform& Rotate(float x, float y, float z){ return Rotate(Vector3(x, y, z)); }
			inline Transform& Scale(float x, float y, float z){ return Scale(Vector3(x, y, z)); }

			inline Ray ToWorld(const Ray& ray) const{
				return Ray(
					Matrix4x4::TPoint(local_world_, ray.origin),
					Matrix4x4::TVector(local_world_, ray.dir).Normalize(),
					ray.t_min, ray.t_max);
			}

			inline RayHit ToWorld(const RayHit& hit) const{
				return RayHit(
					Matrix4x4::TPoint(local_world_, hit.point),
					Matrix4x4::TNormal(local_world_, hit.normal).Normalize());
			}

			inline Ray ToLocal(const Ray& ray) const{
				return Ray(
					Matrix4x4::TPoint(world_local_, ray.origin),
					Matrix4x4::TVector(world_local_, ray.dir),
					ray.t_min, ray.t_max);
			}
{'fraction_non_alphanumeric': 0.1302906680265171, 'fraction_numerical': 0.019377868434472208, 'mean_word_length': 4.502103786816269, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5971050', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1284, 'n_words': 343}