Skip to content

Commit

Permalink
Quaternion constructor with matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardodoria committed Oct 29, 2024
1 parent e08cb42 commit 8175afd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions engine/core/math/Quaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Quaternion::Quaternion(const float angle, const Vector3& rkAxis){
this->fromAngleAxis(angle, rkAxis);
}

Quaternion::Quaternion(const Matrix4& kRot){
this->fromRotationMatrix(kRot);
}

std::string Quaternion::toString() const{
return "Quaternion(" + std::to_string(w) + ", " + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + ")";
}
Expand Down
1 change: 1 addition & 0 deletions engine/core/math/Quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Supernova {
Quaternion(const Vector3* akAxis);
Quaternion(const Vector3& xaxis, const Vector3& yaxis, const Vector3& zaxis);
Quaternion(const float angle, const Vector3& rkAxis);
Quaternion(const Matrix4& kRot);

std::string toString() const;

Expand Down
3 changes: 2 additions & 1 deletion engine/core/script/binding/MathClassesLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ void LuaBinding::registerMathClasses(lua_State *L){
void(const float, const float, const float),
void(const Vector3*),
void(const Vector3&, const Vector3&, const Vector3&),
void(const float, const Vector3&)>()
void(const float, const Vector3&),
void(const Matrix4&)>()
.addStaticProperty("IDENTITY", &Quaternion::IDENTITY)
.addFunction("__tostring", &Quaternion::toString)
.addFunction("__eq", &Quaternion::operator==)
Expand Down

0 comments on commit 8175afd

Please sign in to comment.