- TEST_SPEC.md: Updated test directory structure to reflect Core/Asset, Core/IO, and Resources/<Type> subdirectories - TEST_SPEC.md: Updated module names and test counts (852 total) - TEST_SPEC.md: Updated build commands for new Resources subdirectories - README.md: Updated engine structure with Core/Asset/ and Core/IO/ - README.md: Updated Resources section with layered architecture - README.md: Updated test coverage table with accurate counts
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include "Core/Math/Transform.h"
|
|
#include "Core/Math/Matrix4.h"
|
|
|
|
namespace XCEngine {
|
|
namespace Math {
|
|
|
|
Matrix4 Transform::ToMatrix() const {
|
|
return Matrix4x4::TRS(position, rotation, scale);
|
|
}
|
|
|
|
Transform Transform::Inverse() const {
|
|
Transform result;
|
|
result.rotation = rotation.Inverse();
|
|
result.scale = Vector3::One() / scale;
|
|
result.position = result.rotation * (Vector3::Zero() - position) * result.scale;
|
|
return result;
|
|
}
|
|
|
|
Transform Transform::operator*(const Transform& other) const {
|
|
Transform result;
|
|
result.position = position + rotation * (scale * other.position);
|
|
result.rotation = rotation * other.rotation;
|
|
result.scale = scale * other.scale;
|
|
return result;
|
|
}
|
|
|
|
Vector3 Transform::TransformPoint(const Vector3& point) const {
|
|
return position + rotation * (scale * point);
|
|
}
|
|
|
|
Vector3 Transform::TransformDirection(const Vector3& direction) const {
|
|
return rotation * (scale * direction);
|
|
}
|
|
|
|
Vector3 Transform::InverseTransformPoint(const Vector3& point) const {
|
|
return (rotation.Inverse() * (point - position)) / scale;
|
|
}
|
|
|
|
Vector3 Transform::InverseTransformDirection(const Vector3& direction) const {
|
|
return rotation.Inverse() * direction / scale;
|
|
}
|
|
|
|
} // namespace Math
|
|
} // namespace XCEngine
|