From 53b94cca685174362de42b7db48101499f70d632 Mon Sep 17 00:00:00 2001 From: Matt Larsen Date: Wed, 22 Sep 2021 16:55:41 -0700 Subject: [PATCH] remove namespace (#83) * remove namespace * fix vector constructor --- src/dray/transform_3d.hpp | 70 +++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/dray/transform_3d.hpp b/src/dray/transform_3d.hpp index b6a33b7c..991988f3 100644 --- a/src/dray/transform_3d.hpp +++ b/src/dray/transform_3d.hpp @@ -33,14 +33,14 @@ namespace dray /// transformations, but requires some more computations. /// template -DRAY_EXEC dray::Vec -transform_point (const dray::Matrix &matrix, const dray::Vec &point) +DRAY_EXEC Vec +transform_point (const Matrix &matrix, const Vec &point) { - dray::Vec homogeneousPoint{ point[0], point[1], point[2], T (1) }; - T inverseW = 1 / dray::dot (matrix.get_row (3), homogeneousPoint); - return dray::Vec{ dray::dot (matrix.get_row (0), homogeneousPoint) * inverseW, - dray::dot (matrix.get_row (1), homogeneousPoint) * inverseW, - dray::dot (matrix.get_row (2), homogeneousPoint) * inverseW }; + Vec homogeneousPoint{ point[0], point[1], point[2], T (1) }; + T inverseW = 1 / dot (matrix.get_row (3), homogeneousPoint); + return Vec{ dot (matrix.get_row (0), homogeneousPoint) * inverseW, + dot (matrix.get_row (1), homogeneousPoint) * inverseW, + dot (matrix.get_row (2), homogeneousPoint) * inverseW }; } /// \brief Transform a 3D vector by a transformation matrix. @@ -50,12 +50,12 @@ transform_point (const dray::Matrix &matrix, const dray::Vec &poi /// vectors do not get translated. /// template -DRAY_EXEC dray::Vec -transform_vector (const dray::Matrix &matrix, const dray::Vec &vector) +DRAY_EXEC Vec +transform_vector (const Matrix &matrix, const Vec &vector) { - dray::Vec homogeneousVector{ vector[0], vector[1], vector[2], T (0) }; + Vec homogeneousVector{ vector[0], vector[1], vector[2], T (0) }; homogeneousVector = matrix * homogeneousVector; - return dray::Vec{ homogeneousVector[0], homogeneousVector[1], + return Vec{ homogeneousVector[0], homogeneousVector[1], homogeneousVector[2] }; } @@ -65,9 +65,9 @@ transform_vector (const dray::Matrix &matrix, const dray::Vec &ve /// transformation matrix for those scales. /// template -DRAY_EXEC dray::Matrix scale (const T &scaleX, const T &scaleY, const T &scaleZ) +DRAY_EXEC Matrix scale (const T &scaleX, const T &scaleY, const T &scaleZ) { - dray::Matrix scaleMatrix (T (0)); + Matrix scaleMatrix (T (0)); scaleMatrix (0, 0) = scaleX; scaleMatrix (1, 1) = scaleY; scaleMatrix (2, 2) = scaleZ; @@ -81,9 +81,9 @@ DRAY_EXEC dray::Matrix scale (const T &scaleX, const T &scaleY, const T /// returns a transformation matrix for those scales. /// template -DRAY_EXEC dray::Matrix scale (const dray::Vec &scaleVec) +DRAY_EXEC Matrix scale (const Vec &scaleVec) { - return dray::scale (scaleVec[0], scaleVec[1], scaleVec[2]); + return scale (scaleVec[0], scaleVec[1], scaleVec[2]); } /// \brief Returns a scale matrix. @@ -92,17 +92,17 @@ DRAY_EXEC dray::Matrix scale (const dray::Vec &scaleVec) /// scales. /// template -DRAY_EXEC dray::Matrix Transform3DScale (const T &scale) +DRAY_EXEC Matrix Transform3DScale (const T &scale) { - return dray::scale (scale, scale, scale); + return scale (scale, scale, scale); } /// \brief Returns a translation matrix. /// template -DRAY_EXEC dray::Matrix translate (const T &x, const T &y, const T &z) +DRAY_EXEC Matrix translate (const T &x, const T &y, const T &z) { - dray::Matrix translateMatrix; + Matrix translateMatrix; translateMatrix.identity (); translateMatrix (0, 3) = x; translateMatrix (1, 3) = y; @@ -110,9 +110,9 @@ DRAY_EXEC dray::Matrix translate (const T &x, const T &y, const T &z) return translateMatrix; } template -DRAY_EXEC dray::Matrix translate (const dray::Vec &v) +DRAY_EXEC Matrix translate (const Vec &v) { - return dray::translate (v[0], v[1], v[2]); + return translate (v[0], v[1], v[2]); } /// \brief Returns a rotation matrix. @@ -123,15 +123,15 @@ DRAY_EXEC dray::Matrix translate (const dray::Vec &v) /// rotation will be counterclockwise. /// template -DRAY_EXEC dray::Matrix rotate (T angleDegrees, const dray::Vec &axisOfRotation) +DRAY_EXEC Matrix rotate (T angleDegrees, const Vec &axisOfRotation) { - T angleRadians = dray::pi_180f () * angleDegrees; - dray::Vec normAxis = axisOfRotation; + T angleRadians = pi_180f () * angleDegrees; + Vec normAxis = axisOfRotation; normAxis.normalize (); T sinAngle = sin (angleRadians); T cosAngle = cos (angleRadians); - dray::Matrix matrix; + Matrix matrix; matrix (0, 0) = normAxis[0] * normAxis[0] * (1 - cosAngle) + cosAngle; matrix (0, 1) = normAxis[0] * normAxis[1] * (1 - cosAngle) - normAxis[2] * sinAngle; @@ -156,40 +156,40 @@ DRAY_EXEC dray::Matrix rotate (T angleDegrees, const dray::Vec &a return matrix; } template -DRAY_EXEC dray::Matrix rotate (T angleDegrees, T x, T y, T z) +DRAY_EXEC Matrix rotate (T angleDegrees, T x, T y, T z) { - return dray::rotate (angleDegrees, dray::Vec (x, y, z)); + return rotate (angleDegrees, Vec {{x, y, z}}); } /// \brief Returns a rotation matrix. /// /// Returns a transformation matrix that rotates around the x axis. /// -template DRAY_EXEC dray::Matrix rotate_x (T angleDegrees) +template DRAY_EXEC Matrix rotate_x (T angleDegrees) { - return dray::rotate (angleDegrees, T (1), T (0), T (0)); + return rotate (angleDegrees, T (1), T (0), T (0)); } /// \brief Returns a rotation matrix. /// /// Returns a transformation matrix that rotates around the y axis. /// -template DRAY_EXEC dray::Matrix rotate_y (T angleDegrees) +template DRAY_EXEC Matrix rotate_y (T angleDegrees) { - return dray::rotate (angleDegrees, T (0), T (1), T (0)); + return rotate (angleDegrees, T (0), T (1), T (0)); } /// \brief Returns a rotation matrix. /// /// Returns a transformation matrix that rotates around the z axis. /// -template DRAY_EXEC dray::Matrix rotate_z (T angleDegrees) +template DRAY_EXEC Matrix rotate_z (T angleDegrees) { - return dray::rotate (angleDegrees, T (0), T (0), T (1)); + return rotate (angleDegrees, T (0), T (0), T (1)); } -static DRAY_EXEC dray::Matrix -trackball_matrix (dray::float32 p1x, dray::float32 p1y, dray::float32 p2x, dray::float32 p2y) +static DRAY_EXEC Matrix +trackball_matrix (float32 p1x, float32 p1y, float32 p2x, float32 p2y) { const float32 RADIUS = 0.80f; // z value lookAt x = y = 0.0 const float32 COMPRESSION = 3.5f; // multipliers for x and y.