Skip to content

Commit

Permalink
update epsilon value
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud committed Apr 18, 2024
1 parent 5dbf27b commit 106dbb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions clic/include/transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ class AffineTransform
matrix rotation_matrix = matrix::Identity();

// compute rotation values
const float epsilon = std::numeric_limits<float>::epsilon();
const float angle_rad = deg_to_rad(angle_deg);
const float angle_cos = (std::abs(std::cos(angle_rad)) < 1e-6) ? 0 : std::cos(angle_rad);
const float angle_sin = (std::abs(std::sin(angle_rad)) < 1e-6) ? 0 : std::sin(angle_rad);
const float angle_cos_temp = std::cos(angle_rad);
const float angle_sin_temp = std::sin(angle_rad);
const float angle_cos = (std::abs(angle_cos_temp) < epsilon) ? 0 : angle_cos_temp;
const float angle_sin = (std::abs(angle_sin_temp) < epsilon) ? 0 : angle_sin_temp;

// populate the rotation matrix based on the axis
switch (axis)
Expand Down Expand Up @@ -372,7 +375,7 @@ class AffineTransform
static auto
shear_angle_to_shear_factor(float angle_deg) -> float
{
return 1.0F / std::tan((90 - angle_deg) * M_PI / 180);
return static_cast<float>(1.0 / std::tan((90.0 - angle_deg) * M_PI / 180.0));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/tier7/test_rotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST_P(TestRotate, rotate)
auto gpu_input = cle::Array::create(5, 5, 1, 2, cle::dType::FLOAT, cle::mType::BUFFER, device);
gpu_input->write(input.data());

auto gpu_output = cle::tier7::rotate_func(device, gpu_input, nullptr, 0, 0, 45, false, false, false);
auto gpu_output = cle::tier7::rotate_func(device, gpu_input, nullptr, 0, 0, 45.0, false, false, false);

gpu_output->read(output.data());
for (int i = 0; i < output.size(); i++)
Expand Down

0 comments on commit 106dbb9

Please sign in to comment.