Skip to content

Add getters for yaw, azimuth and elevation#2499

Open
AbbasReads wants to merge 34 commits intof3d-app:masterfrom
AbbasReads:getters
Open

Add getters for yaw, azimuth and elevation#2499
AbbasReads wants to merge 34 commits intof3d-app:masterfrom
AbbasReads:getters

Conversation

@AbbasReads
Copy link
Copy Markdown

Added getters for yaw, azimuth and elevation, and python bindings for them

Issue ticket number and link if any

Checklist for finalizing the PR

  • I have performed a self-review of my code
  • I have added tests for new features and bugfixes
  • I have added documentation for new features
  • If it is a modifying the libf3d API, I have updated bindings
  • If it is a modifying the .github/workflows/versions.json, I have updated timestamp

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 7, 2025

You are modifying libf3d public API! ⚠️Please update bindings accordingly⚠️!
You can find them in their respective directories: python, java, webassembly.

Comment thread library/src/camera_impl.cxx Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.48%. Comparing base (e3651cc) to head (7d82ce5).
⚠️ Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
library/src/camera_impl.cxx 92.85% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2499      +/-   ##
==========================================
+ Coverage   96.43%   96.48%   +0.04%     
==========================================
  Files         138      140       +2     
  Lines       12047    12192     +145     
==========================================
+ Hits        11618    11763     +145     
  Misses        429      429              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread library/src/camera_impl.cxx Outdated
@mwestphal
Copy link
Copy Markdown
Member

please rebase on latest master

AbbasReads and others added 24 commits October 30, 2025 15:43
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
Co-authored-by: Mathieu Westphal <mathieu.westphal@gmail.com>
…assertions to use pytest.approx for floating-point comparisons
Comment thread library/public/camera.h
[[nodiscard]] virtual camera_state_t getState() const = 0;
/** Get the complete state of the camera into the provided arg */
virtual void getState(camera_state_t& state) const = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not remove

vector3_t orthogonalizedUp;
cam->GetViewUp(orthogonalizedUp.data());
static constexpr double EPSILON = 128 * std::numeric_limits<double>::epsilon();
for (size_t i = 0; vtkMath::Norm(orthogonalizedUp.data()) < EPSILON && i < up.size(); i++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (size_t i = 0; vtkMath::Norm(orthogonalizedUp.data()) < EPSILON && i < up.size(); i++)
for (size_t i = 0; vtkMath::Norm(orthogonalizedUp.data()) < ::EPSILON && i < up.size(); i++)

vtkMath::Normalize(dir.data());
vtkMath::Normalize(up);

if (vtkMath::Norm(dir.data()) <= EPSILON)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (vtkMath::Norm(dir.data()) <= EPSILON)
if (vtkMath::Norm(dir.data()) <= ::EPSILON)

}

// Project forward vector onto up vector
if (abs(vtkMath::AngleBetweenVectors(dir.data(), up) - vtkMath::Pi() / 2) <= EPSILON)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (abs(vtkMath::AngleBetweenVectors(dir.data(), up) - vtkMath::Pi() / 2) <= EPSILON)
if (abs(vtkMath::AngleBetweenVectors(dir.data(), up) - vtkMath::Pi() / 2) <= ::EPSILON)


// Projection of forward vector along the plane perpendicular to up vector
vtkMath::Subtract(dir, projectedAlongUp, projected);
if (vtkMath::Norm(projected.data()) <= EPSILON)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (vtkMath::Norm(projected.data()) <= EPSILON)
if (vtkMath::Norm(projected.data()) <= ::EPSILON)

Copy link
Copy Markdown
Member

@mwestphal mwestphal Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update F3DEmscriptenBindings.cxx and add a test in webassembly/testing/test_camera.js


if (vtkMath::Norm(dir.data()) <= EPSILON)
{
return 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test covering this

vtkMath::Subtract(dir, projectedAlongUp, projected);
if (vtkMath::Norm(projected.data()) <= EPSILON)
{
return 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test covering this

Copy link
Copy Markdown
Member

@mwestphal mwestphal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes needed

@mwestphal
Copy link
Copy Markdown
Member

Need any help moving forward @AbbasReads ?

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 10, 2025

Style Checks CI failed:

diff --git a/library/testing/TestSDKCamera.cxx b/library/testing/TestSDKCamera.cxx
index c9fccdb..eacec45 100644
--- a/library/testing/TestSDKCamera.cxx
+++ b/library/testing/TestSDKCamera.cxx
@@ -179,7 +179,8 @@ int TestSDKCamera([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
   // }
 
   // cam.yaw(90.0);
-  // if (!compareDouble(cam.getYaw(), 90.0, 1e-6) || !compareDouble(cam.getElevation(), 0.0, 1e-6) ||
+  // if (!compareDouble(cam.getYaw(), 90.0, 1e-6) || !compareDouble(cam.getElevation(), 0.0, 1e-6)
+  // ||
   //   !compareDouble(cam.getAzimuth(), 90.0, 1e-6))
   // {
   //   std::cerr << "After yaw(90): unexpected orientation\n"
@@ -190,7 +191,8 @@ int TestSDKCamera([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
   // }
 
   // cam.elevation(45.0);
-  // if (!compareDouble(cam.getYaw(), 90.0, 1e-6) || !compareDouble(cam.getElevation(), 45.0, 1e-6) ||
+  // if (!compareDouble(cam.getYaw(), 90.0, 1e-6) || !compareDouble(cam.getElevation(), 45.0, 1e-6)
+  // ||
   //   !compareDouble(cam.getAzimuth(), 90.0, 1e-6))
   // {
   //   std::cerr << "After elevation(45): unexpected orientation\n"
@@ -201,7 +203,8 @@ int TestSDKCamera([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
   // }
 
   // cam.azimuth(90);
-  // if (!compareDouble(cam.getYaw(), 180.0, 1e-6) || !compareDouble(cam.getElevation(), 0.0, 1e-6) ||
+  // if (!compareDouble(cam.getYaw(), 180.0, 1e-6) || !compareDouble(cam.getElevation(), 0.0, 1e-6)
+  // ||
   //   !compareDouble(cam.getAzimuth(), 180.0, 1e-6))
   // {
   //   std::cerr << "After azimuth(90): unexpected orientation\n"
diff --git a/webassembly/testing/test_camera.js b/webassembly/testing/test_camera.js
index a108953..3863df5 100644
--- a/webassembly/testing/test_camera.js
+++ b/webassembly/testing/test_camera.js
@@ -48,8 +48,14 @@ const settings = {
     console.log("Yaw:", camera.getYaw());
     console.log("Elevation:", camera.getElevation());
 
-    utils.assert(Math.abs(camera.getYaw() - 45) < 0.01, "Yaw should be 45 after yaw(45)");
-    utils.assert(Math.abs(camera.getElevation()) < 0.01, "Elevation should remain 0");
+    utils.assert(
+      Math.abs(camera.getYaw() - 45) < 0.01,
+      "Yaw should be 45 after yaw(45)",
+    );
+    utils.assert(
+      Math.abs(camera.getElevation()) < 0.01,
+      "Elevation should remain 0",
+    );
 
     // Test elevation rotation
     // camera.resetToDefault();

@mwestphal
Copy link
Copy Markdown
Member

Hi @AbbasReads , still wokring on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants