Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added camera getters for ease of use #1994

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions library/private/camera_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class camera_impl : public camera
camera& setCurrentAsDefault() override;
camera& resetToDefault() override;
camera& resetToBounds(double zoomFactor = 0.9) override;

// New getters
angle_deg_t getYaw() const;
angle_deg_t getAzimuth() const;
angle_deg_t getElevation() const;

///@}

/**
Expand Down
1 change: 1 addition & 0 deletions library/public/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class F3D_EXPORT camera
*/
virtual camera& resetToBounds(double zoomFactor = 0.9) = 0;


protected:
//! @cond
camera() = default;
Expand Down
24 changes: 24 additions & 0 deletions library/src/camera_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,27 @@ vtkCamera* camera_impl::GetVTKCamera()
return this->Internals->VTKRenderer->GetActiveCamera();
}
};

//----------------------------------------------------------------------------
angle_deg_t camera_impl::getYaw() const
{
vtkCamera* cam = this->GetVTKCamera();
double* dir = cam->GetDirectionOfProjection();
return vtkMath::DegreesFromRadians(std::atan2(dir[2], dir[0]));
}

//----------------------------------------------------------------------------
angle_deg_t camera_impl::getAzimuth() const
{
vtkCamera* cam = this->GetVTKCamera();
double* dir = cam->GetDirectionOfProjection();
return vtkMath::DegreesFromRadians(std::atan2(-dir[0], -dir[2]));
}

//----------------------------------------------------------------------------
angle_deg_t camera_impl::getElevation() const
{
vtkCamera* cam = this->GetVTKCamera();
double* dir = cam->GetDirectionOfProjection();
return vtkMath::DegreesFromRadians(std::asin(dir[1]));
}
Loading