docs: update TEST_SPEC.md and README.md to reflect new directory structure
- 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
This commit is contained in:
44
engine/src/Core/Math/Transform.cpp
Normal file
44
engine/src/Core/Math/Transform.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user