diff --git a/vtkm/Transform3D.h b/vtkm/Transform3D.h index c8ce3e3af..28472cf6b 100644 --- a/vtkm/Transform3D.h +++ b/vtkm/Transform3D.h @@ -135,18 +135,17 @@ vtkm::Matrix Transform3DTranslate(const vtkm::Vec &v) /// \brief Returns a rotation matrix. /// -/// Given an angle (in radians) and an axis of rotation, returns a +/// Given an angle (in degrees) and an axis of rotation, returns a /// transformation matrix that rotates around the given axis. The rotation /// follows the right-hand rule, so if the vector points toward the user, the /// rotation will be counterclockwise. /// -/// Note that, unlike with OpenGL, the angle is given in radians, not degrees. -/// template VTKM_EXEC_CONT_EXPORT -vtkm::Matrix Transform3DRotate(T angleRadians, +vtkm::Matrix Transform3DRotate(T angleDegrees, const vtkm::Vec &axisOfRotation) { + T angleRadians = static_cast(vtkm::Pi()/180)*angleDegrees; const vtkm::Vec normAxis = vtkm::Normal(axisOfRotation); T sinAngle = vtkm::Sin(angleRadians); T cosAngle = vtkm::Cos(angleRadians); @@ -177,9 +176,9 @@ vtkm::Matrix Transform3DRotate(T angleRadians, } template VTKM_EXEC_CONT_EXPORT -vtkm::Matrix Transform3DRotate(T angleRadians, T x, T y, T z) +vtkm::Matrix Transform3DRotate(T angleDegrees, T x, T y, T z) { - return vtkm::Transform3DRotate(angleRadians, vtkm::Vec(x,y,z)); + return vtkm::Transform3DRotate(angleDegrees, vtkm::Vec(x,y,z)); } /// \brief Returns a rotation matrix. @@ -188,9 +187,9 @@ vtkm::Matrix Transform3DRotate(T angleRadians, T x, T y, T z) /// template VTKM_EXEC_CONT_EXPORT -vtkm::Matrix Transform3DRotateX(T angleRadians) +vtkm::Matrix Transform3DRotateX(T angleDegrees) { - return vtkm::Transform3DRotate(angleRadians, T(1), T(0), T(0)); + return vtkm::Transform3DRotate(angleDegrees, T(1), T(0), T(0)); } /// \brief Returns a rotation matrix. @@ -199,9 +198,9 @@ vtkm::Matrix Transform3DRotateX(T angleRadians) /// template VTKM_EXEC_CONT_EXPORT -vtkm::Matrix Transform3DRotateY(T angleRadians) +vtkm::Matrix Transform3DRotateY(T angleDegrees) { - return vtkm::Transform3DRotate(angleRadians, T(0), T(1), T(0)); + return vtkm::Transform3DRotate(angleDegrees, T(0), T(1), T(0)); } /// \brief Returns a rotation matrix. @@ -210,9 +209,9 @@ vtkm::Matrix Transform3DRotateY(T angleRadians) /// template VTKM_EXEC_CONT_EXPORT -vtkm::Matrix Transform3DRotateZ(T angleRadians) +vtkm::Matrix Transform3DRotateZ(T angleDegrees) { - return vtkm::Transform3DRotate(angleRadians, T(0), T(0), T(1)); + return vtkm::Transform3DRotate(angleDegrees, T(0), T(0), T(1)); } } // namespace vtkm diff --git a/vtkm/rendering/Camera.h b/vtkm/rendering/Camera.h index 007b8e46a..674887d10 100644 --- a/vtkm/rendering/Camera.h +++ b/vtkm/rendering/Camera.h @@ -640,53 +640,53 @@ public: /// \brief Roll the camera /// /// Rotates the camera around the view direction by the given angle. The - /// angle is given in radians. + /// angle is given in degrees. /// /// Roll is currently only supported for 3D cameras. /// VTKM_CONT_EXPORT - void Roll(vtkm::Float32 angleRadians) + void Roll(vtkm::Float32 angleDegrees) { vtkm::Vec directionOfProjection = this->GetLookAt() - this->GetPosition(); vtkm::Matrix rotateTransform = - vtkm::Transform3DRotate(angleRadians, directionOfProjection); + vtkm::Transform3DRotate(angleDegrees, directionOfProjection); this->SetViewUp(vtkm::Transform3DVector(rotateTransform,this->GetViewUp())); } VTKM_CONT_EXPORT - void Roll(vtkm::Float64 angleRadians) + void Roll(vtkm::Float64 angleDegrees) { - this->Roll(static_cast(angleRadians)); + this->Roll(static_cast(angleDegrees)); } /// \brief Rotate the camera about the view up vector centered at the focal point. /// /// Note that the view up vector is whatever was set via SetViewUp, and is /// not necesarily perpendicular to the direction of projection. The angle is - /// given in radians. + /// given in degrees. /// /// Azimuth only makes sense for 3D cameras, so the camera mode will be set /// to 3D when this method is called. /// VTKM_CONT_EXPORT - void Azimuth(vtkm::Float32 angleRadians) + void Azimuth(vtkm::Float32 angleDegrees) { // Translate to the focal point (LookAt), rotate about view up, and // translate back again. vtkm::Matrix transform = vtkm::Transform3DTranslate(this->GetLookAt()); transform = vtkm::MatrixMultiply( - transform, vtkm::Transform3DRotate(angleRadians, this->GetViewUp())); + transform, vtkm::Transform3DRotate(angleDegrees, this->GetViewUp())); transform = vtkm::MatrixMultiply( transform, vtkm::Transform3DTranslate(-this->GetLookAt())); this->SetPosition(vtkm::Transform3DPoint(transform, this->GetPosition())); } VTKM_CONT_EXPORT - void Azimuth(vtkm::Float64 angleRadians) + void Azimuth(vtkm::Float64 angleDegrees) { - this->Azimuth(static_cast(angleRadians)); + this->Azimuth(static_cast(angleDegrees)); } /// \brief Rotate the camera vertically around the focal point. @@ -694,13 +694,13 @@ public: /// Specifically, this rotates the camera about the cross product of the /// negative of the direction of projection and the view up vector, using the /// focal point (LookAt) as the center of rotation. The angle is given - /// in radians. + /// in degrees. /// /// Elevation only makes sense for 3D cameras, so the camera mode will be set /// to 3D when this method is called. /// VTKM_CONT_EXPORT - void Elevation(vtkm::Float32 angleRadians) + void Elevation(vtkm::Float32 angleDegrees) { vtkm::Vec axisOfRotation = vtkm::Cross(this->GetPosition() - this->GetLookAt(), this->GetViewUp()); @@ -710,16 +710,16 @@ public: vtkm::Matrix transform = vtkm::Transform3DTranslate(this->GetLookAt()); transform = vtkm::MatrixMultiply( - transform, vtkm::Transform3DRotate(angleRadians, axisOfRotation)); + transform, vtkm::Transform3DRotate(angleDegrees, axisOfRotation)); transform = vtkm::MatrixMultiply( transform, vtkm::Transform3DTranslate(-this->GetLookAt())); this->SetPosition(vtkm::Transform3DPoint(transform, this->GetPosition())); } VTKM_CONT_EXPORT - void Elevation(vtkm::Float64 angleRadians) + void Elevation(vtkm::Float64 angleDegrees) { - this->Elevation(static_cast(angleRadians)); + this->Elevation(static_cast(angleDegrees)); } /// \brief Move the camera toward or away from the focal point. diff --git a/vtkm/rendering/testing/UnitTestMapperOSMesa.cxx b/vtkm/rendering/testing/UnitTestMapperOSMesa.cxx index 0f72bfe29..45ee2a92f 100644 --- a/vtkm/rendering/testing/UnitTestMapperOSMesa.cxx +++ b/vtkm/rendering/testing/UnitTestMapperOSMesa.cxx @@ -36,8 +36,8 @@ void Set3DView(vtkm::rendering::Camera &camera, //set up a default view camera = vtkm::rendering::Camera(); camera.ResetToBounds(coordsBounds); - camera.Azimuth(static_cast(vtkm::Pi_4())); - camera.Elevation(static_cast(vtkm::Pi_4())); + camera.Azimuth(45.0f); + camera.Elevation(45.0f); std::cout << "Camera3d: pos: " << camera.GetPosition() << std::endl; std::cout << " lookAt: " << camera.GetLookAt() << std::endl; diff --git a/vtkm/rendering/testing/UnitTestMapperRayTracer.cxx b/vtkm/rendering/testing/UnitTestMapperRayTracer.cxx index 9c40647dc..b2a5db796 100644 --- a/vtkm/rendering/testing/UnitTestMapperRayTracer.cxx +++ b/vtkm/rendering/testing/UnitTestMapperRayTracer.cxx @@ -36,8 +36,8 @@ void Set3DView(vtkm::rendering::Camera &camera, //set up a default view camera = vtkm::rendering::Camera(); camera.ResetToBounds(coordsBounds); - camera.Azimuth(static_cast(vtkm::Pi_4())); - camera.Elevation(static_cast(vtkm::Pi_4())); + camera.Azimuth(45.0f); + camera.Elevation(45.0f); std::cout << "Camera3d: pos: " << camera.GetPosition() << std::endl; std::cout << " lookAt: " << camera.GetLookAt() << std::endl; diff --git a/vtkm/rendering/testing/UnitTestMapperVolume.cxx b/vtkm/rendering/testing/UnitTestMapperVolume.cxx index d26260740..e416abb81 100644 --- a/vtkm/rendering/testing/UnitTestMapperVolume.cxx +++ b/vtkm/rendering/testing/UnitTestMapperVolume.cxx @@ -37,8 +37,8 @@ void Set3DView(vtkm::rendering::Camera &camera, //set up a default view camera = vtkm::rendering::Camera(); camera.ResetToBounds(coordsBounds); - camera.Azimuth(static_cast(vtkm::Pi_4())); - camera.Elevation(static_cast(vtkm::Pi_4())); + camera.Azimuth(45.0f); + camera.Elevation(45.0f); std::cout << "Camera3d: pos: " << camera.GetPosition() << std::endl; std::cout << " lookAt: " << camera.GetLookAt() << std::endl; diff --git a/vtkm/testing/UnitTestTransform3D.cxx b/vtkm/testing/UnitTestTransform3D.cxx index 23c54b6d1..43867023d 100644 --- a/vtkm/testing/UnitTestTransform3D.cxx +++ b/vtkm/testing/UnitTestTransform3D.cxx @@ -115,7 +115,7 @@ struct TransformTests Vec startPoint = this->RandomVector(); std::cout << " Starting point: " << startPoint << std::endl; - const T ninetyDegrees = T(vtkm::Pi_2()); + const T ninetyDegrees = T(90); std::cout << "--Rotate 90 degrees around X" << std::endl; Transform rotateX = vtkm::Transform3DRotateX(ninetyDegrees);