Skip to content

Commit

Permalink
Merge branch 'dev' into physx
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Feb 26, 2024
2 parents e18aefc + 2d29b5a commit 4375aed
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 92 deletions.
6 changes: 3 additions & 3 deletions examples/projects/Crane3R/Actuator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class Object3DActuator: public Actuator {
float getProcessOutput() override {
switch (axis_) {
case X:
return obj_->rotation.x();
return obj_->rotation.x;
case Y:
return obj_->rotation.y();
return obj_->rotation.y;
case Z:
return obj_->rotation.z();
return obj_->rotation.z;
default:
throw std::runtime_error("");
}
Expand Down
6 changes: 3 additions & 3 deletions examples/projects/Crane3R/Crane3R.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ std::shared_ptr<Crane3R> Crane3R::create() {
std::vector<Angle> Crane3R::getValues() const {

std::vector<Angle> angles{
Angle::radians(parts_[0]->rotation.z()),
Angle::radians(parts_[1]->rotation.y()),
Angle::radians(parts_[2]->rotation.y()),
Angle::radians(parts_[0]->rotation.z),
Angle::radians(parts_[1]->rotation.y),
Angle::radians(parts_[2]->rotation.y),
};

return angles;
Expand Down
10 changes: 5 additions & 5 deletions examples/projects/Youbot/Youbot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ struct Youbot: Object3D, KeyListener {

std::vector<float> getJointValues() {
return {
arm_joint1->rotation.z() * math::RAD2DEG,
arm_joint2->rotation.z() * math::RAD2DEG + 90,
arm_joint3->rotation.z() * math::RAD2DEG + 90,
arm_joint4->rotation.z() * math::RAD2DEG,
arm_joint5->rotation.z() * math::RAD2DEG,
arm_joint1->rotation.z * math::RAD2DEG,
arm_joint2->rotation.z * math::RAD2DEG + 90,
arm_joint3->rotation.z * math::RAD2DEG + 90,
arm_joint4->rotation.z * math::RAD2DEG,
arm_joint5->rotation.z * math::RAD2DEG,
};
}

Expand Down
2 changes: 1 addition & 1 deletion include/threepp/math/float_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace threepp {
float_view(float value = 0)
: value_(value) {}

inline float operator()() const {
inline operator float() const {

return value_;
}
Expand Down
4 changes: 2 additions & 2 deletions src/threepp/math/Matrix4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Matrix4& Matrix4::makeRotationFromEuler(const Euler& ee) {

auto& te = this->elements;

const float x = ee.x(), y = ee.y(), z = ee.z();
const float x = ee.x, y = ee.y, z = ee.z;
const float a = std::cos(x), b = std::sin(x);
const float c = std::cos(y), d = std::sin(y);
const float e = std::cos(z), f = std::sin(z);
Expand Down Expand Up @@ -638,7 +638,7 @@ Matrix4& Matrix4::compose(const Vector3& position, const Quaternion& quaternion,

auto& te = this->elements;

const float x = quaternion.x(), y = quaternion.y(), z = quaternion.z(), w = quaternion.w();
const float x = quaternion.x, y = quaternion.y, z = quaternion.z, w = quaternion.w;
const float x2 = x + x, y2 = y + y, z2 = z + z;
const float xx = x * x2, xy = x * y2, xz = x * z2;
const float yy = y * y2, yz = y * z2, zz = z * z2;
Expand Down
24 changes: 12 additions & 12 deletions src/threepp/math/Quaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Quaternion::Quaternion(float x, float y, float z, float w)
float Quaternion::operator[](unsigned int index) const {
switch (index) {
case 0:
return x();
return x;
case 1:
return y();
return y;
case 2:
return z();
return z;
case 3:
return w();
return w;
default:
throw std::runtime_error("index out of bound: " + std::to_string(index));
}
Expand All @@ -44,10 +44,10 @@ Quaternion& Quaternion::set(float x, float y, float z, float w) {

Quaternion& Quaternion::copy(const Quaternion& quaternion) {

this->x.value_ = quaternion.x();
this->y.value_ = quaternion.y();
this->z.value_ = quaternion.z();
this->w.value_ = quaternion.w();
this->x.value_ = quaternion.x;
this->y.value_ = quaternion.y;
this->z.value_ = quaternion.z;
this->w.value_ = quaternion.w;

this->onChangeCallback_();

Expand All @@ -56,7 +56,7 @@ Quaternion& Quaternion::copy(const Quaternion& quaternion) {

Quaternion& Quaternion::setFromEuler(const Euler& euler, bool update) {

const auto x = euler.x(), y = euler.y(), z = euler.z();
const auto x = euler.x, y = euler.y, z = euler.z;
const auto order = euler.order_;

// http://www.mathworks.com/matlabcentral/fileexchange/
Expand Down Expand Up @@ -406,8 +406,8 @@ Quaternion& Quaternion::multiplyQuaternions(const Quaternion& a, const Quaternio

// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm

const auto qax = a.x(), qay = a.y(), qaz = a.z(), qaw = a.w();
const auto qbx = b.x(), qby = b.y(), qbz = b.z(), qbw = b.w();
const auto qax = a.x, qay = a.y, qaz = a.z, qaw = a.w;
const auto qbx = b.x, qby = b.y, qbz = b.z, qbw = b.w;

this->x.value_ = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
this->y.value_ = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
Expand All @@ -426,7 +426,7 @@ Quaternion Quaternion::clone() const {

bool Quaternion::equals(const Quaternion& v) const {

return ((v.x() == this->x()) && (v.y() == this->y()) && (v.z() == this->z()) && (v.w() == this->w()));
return ((v.x == this->x) && (v.y == this->y) && (v.z == this->z) && (v.w == this->w));
}

Quaternion& Quaternion::_onChange(std::function<void()> callback) {
Expand Down
2 changes: 1 addition & 1 deletion src/threepp/math/Vector3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Vector3& Vector3::applyMatrix4(const Matrix4& m) {
Vector3& Vector3::applyQuaternion(const Quaternion& q) {

const auto x = this->x, y = this->y, z = this->z;
const auto qx = q.x(), qy = q.y(), qz = q.z(), qw = q.w();
const auto qx = q.x, qy = q.y, qz = q.z, qw = q.w;

// calculate quat * vector

Expand Down
12 changes: 6 additions & 6 deletions tests/core/Object3D_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ TEST_CASE("applyMatrix4") {
a->applyMatrix4(m);

REQUIRE(a->position == expectedPos);
auto result = std::abs(a->quaternion.x() - expectedQuat.x()) <= eps &&
std::abs(a->quaternion.y() - expectedQuat.y()) <= eps &&
std::abs(a->quaternion.z() - expectedQuat.z()) <= eps;
auto result = std::abs(a->quaternion.x - expectedQuat.x) <= eps &&
std::abs(a->quaternion.y - expectedQuat.y) <= eps &&
std::abs(a->quaternion.z - expectedQuat.z) <= eps;
REQUIRE(result);
}

Expand All @@ -49,9 +49,9 @@ TEST_CASE("applyQuaternion") {
a->quaternion.set(0.25, 0.25, 0.25, 0.25);
a->applyQuaternion(quat);

auto result = std::abs(a->quaternion.x() - expected.x()) <= eps &&
std::abs(a->quaternion.y() - expected.y()) <= eps &&
std::abs(a->quaternion.z() - expected.z()) <= eps;
auto result = std::abs(a->quaternion.x - expected.x) <= eps &&
std::abs(a->quaternion.y - expected.y) <= eps &&
std::abs(a->quaternion.z - expected.z) <= eps;
REQUIRE(result);
}

Expand Down
Loading

0 comments on commit 4375aed

Please sign in to comment.