Re: [eigen] Rotations and unit vectors |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: Eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] Rotations and unit vectors*From*: Hauke Heibel <hauke.heibel@xxxxxxxxx>*Date*: Mon, 13 May 2013 07:55:46 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=0YjIJu+hz/JXyheoXQ9PBnt1m8NMyL+7AS5UuwSGTbg=; b=JUpJVyV8SAbCLEga9QVXi00bhOOslwPrCB7MO1h0HPOK+AaoCgjUoR4QUnZR2Js+T7 kn5M1TvrY3Yh68GTDqeFl93/7Th3acxCCrA/3fowgTcy3xzO3lkAMxJOk4B8YUG9aMR/ XWk+efUnRO8+UfU55fPbQPV+qXJ5DwJNsFfE59SIy3O5ejELn5fwlFEdX3QEIHXhnPXw SKHUx+3jev0bliO+H2ah2tgAFWZvG4uhvP3Jfy3gN8oTcHKhXdSddLV87p2uR8/sbb7t 9vbwxpln45xFh8IcXb3xXlOM/fsLvHiwrQ+qBgnXoUUoTWufQc8vpM1cxwiNa/O9m/LU I/1A==

Just to summarize. I think in general, we agree that we should try to cover at least the most basic cases in which the user can create invalid objects. So far we have two reasonable options

a) use asserts enabled ifndef DNDEBUG

b) use NaNs to signal a wrong usage

Personally I am still for option a), despite Benoit's reasoning. The main question remaining for both versions is how to choose a good threshold. Here, we also have two options on the table

a) Eigen's dummy precision (I think something like 10e-15 for double and 1-e-5 for float)

b) sqrt( numeric_limits<Scalar>::epsilon )

a) probably provides better support for user defined scalars and b) is less strict than a) and is more unlikely to raise asserts when they are not necessary

Regards,

Hauke

On Wed, May 8, 2013 at 1:42 PM, Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

On 07.05.2013 18:45, Dick Lyon wrote:I guess, normalizing every time would be more consistent then. I assume an inverse sqrt is more expensive than a comparison and a branch, but as both need to be done quite often, it could even be cheaper on average.

How about this: compute the norm of the unit vector, and compare it to 1..

If it's not very close, don't fail out, but normalize the vector.

That would again be another flag which changes global behavior.

Or wrap existing functions with new versions that check and correct norms

of unit vectors, so the programmer can use one or the other; or have a mode

flag that controls whether to normalize; you could even have a mode to fail

out, but people who want a strong check.

Maybe a CHECK_UNIT_VECTOR_NORM(vec, tolerance) that would compile to

nothing, or to an assert, or to a re-normalization, depending on mode.

And, especially if you switch from auto-normalization to do-nothing, you can get very subtle bugs (both versions work, but the latter gets more and more inaccurate over time).

I would vote for just asserting accuracy (which will be disabled in NDEBUG mode), possibly with a customizable tolerance. Most importantly, a program which runs fine in debug mode should give the same results in release mode. And a program that fails in debug mode shall be allowed to give undefined results in release mode.

As for asserting or throwing:

It is possible to change eigen_assert to throw instead of assert and so far eigen_assert is the only way Eigen indicates non-recoverable errors (though mostly these are dimension mismatches etc)

Christoph

--

----------------------------------------------

Dipl.-Inf., Dipl.-Math. Christoph Hertzberg

Cartesium 0.049

Universität Bremen

Enrique-Schmidt-Straße 5

28359 Bremen

Tel: +49 (421) 218-64252

----------------------------------------------

**Follow-Ups**:**[eigen] Link error using -On flag (g++ 4.7.2)***From:*Charly Mourglia

**Re: [eigen] Rotations and unit vectors***From:*Gael Guennebaud

**References**:**[eigen] Rotations and unit vectors***From:*Hauke Heibel

**Re: [eigen] Rotations and unit vectors***From:*Robert Lupton the Good

**Re: [eigen] Rotations and unit vectors***From:*Benoit Jacob

**Re: [eigen] Rotations and unit vectors***From:*Hauke Heibel

**Re: [eigen] Rotations and unit vectors***From:*Benoit Jacob

**Re: [eigen] Rotations and unit vectors***From:*Dick Lyon

**Re: [eigen] Rotations and unit vectors***From:*Christoph Hertzberg

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Eigen and Visualization Toolkit (VTK)** - Next by Date:
**[eigen] Link error using -On flag (g++ 4.7.2)** - Previous by thread:
**Re: [eigen] Rotations and unit vectors** - Next by thread:
**[eigen] Link error using -On flag (g++ 4.7.2)**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |