Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Comparison between 2D and 3D Affine transforms

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Comparison between 2D and 3D Affine transforms


Chronological Thread 
  • From: James Cook <>
  • To:
  • Subject: Re: [cgal-discuss] Comparison between 2D and 3D Affine transforms
  • Date: Tue, 5 May 2015 09:21:07 +0100

As I expected. 
Thank you.


On Tue, May 5, 2015 at 7:50 AM, Sebastien Loriot (GeometryFactory) <> wrote:
An affine transformation is a construction so if you're using a
non-exact number type (like double) you have no guarantee on
the correctness of the result (nor that it will end up without
crashing).

For more details see:
http://www.cgal.org/FAQ.html#inexact_NT

Sebastien.


On 04/28/2015 01:37 PM, James Cook wrote:
Dear Mailing list,

Cutting to the chase: Is it expected that the following test should fail?

The test compares results of a 2D and a 3D AffineTransformation. Both
are constructed to have unit scaling and zero offsets in the y and z
direction, but to have non-zero and non-unity scaling and offset in the
x direction. All other off-diagonal elements are zero. It is my belief
that these transformations are identical in the x and y directions, and
hence should produce identical results.

|
TEST(TransformerTest, testCGALAffine) {
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
using Float = typename K::FT;
using Transformation_2 = K::Aff_transformation_2;
using Transformation_3 = K::Aff_transformation_3;
using Point_2 = typename K::Point_2;
using Point_3 = typename K::Point_3;

double lowerCorner(17.005142946538115);
double upperCorner(91.940521484752139);
int resolution = 48;
double tmpScaleX((upperCorner - lowerCorner) / resolution);
Float scaleX(tmpScaleX);
Float zero(0);
Float unit(1);

// create a 2D voxel to world transform
Transformation_2 transformV2W_2(scaleX, zero, Float(lowerCorner),
                                 zero, unit, zero,
                                 unit);
// create it's inverse: a 2D world to voxel transform
auto transformW2V_2 = transformV2W_2.inverse();

// create a 3D voxel to world transform
Transformation_3 transformV2W_3(scaleX, zero, zero, Float(lowerCorner),
                                 zero, unit, zero, zero,
                                 zero, zero, unit, zero,
                                 unit);
// create it's inverse: a 3D world to voxel transform
auto transformW2V_3 = transformV2W_3.inverse();

for (int i = 0; i < 3; ++i) {
     for (int j = 0; j < 2; ++j) {
         EXPECT_EQ(transformV2W_2.cartesian(i, j), transformV2W_3.cartesian(i, j)) << i << ", " << j;
         EXPECT_EQ(transformW2V_2.cartesian(i, j), transformW2V_3.cartesian(i, j)) << i << ", " << j;
     }
}

std::mt19937_64 rng(0);
std::uniform_real_distribution<double> randReal(0, resolution);
// compare the results of 2D and 3D transformations of random locations
for (int i = 0; i < static_cast<int>(1e4); ++i) {
     Float x(randReal(rng));
     Float y(randReal(rng));
     auto world_2 = transformV2W_2(Point_2(x, y));
     auto world_3 = transformV2W_3(Point_3(x, y, 0));
     EXPECT_EQ(world_2.x(), world_3.x()) << world_2 << ", " << world_3;

     auto voxel_2 = transformW2V_2(world_2);
     auto voxel_3 = transformW2V_3(world_3);
     EXPECT_EQ(voxel_2.x(), voxel_3.x()) << voxel_2 << ", " << voxel_3;

}
}
|

|

Furthermore I have found that the test passes if I use this Kernel:

|using K = CGAL::Exact_predicates_exact_constructions_kernel;
|

Is it to be expected that the test passes if I use this Kernel? Should
the test fail with either kernel or pass with either kernel?

|
|Many thanks for your attention,|
|James|


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss






Archive powered by MHonArc 2.6.18.

Top of Page