This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Using Vector4f with Transform3f's linear part ?

Tags: None
(comma "," separated)
lpierre
Registered Member
Posts
1
Karma
0
Hi everyone!

I need some advice about 3D affine transforms, and the necessary separate handling of points, vectors, and normals.

I already know that I should use the Eigen::Transform class (in Affine mode), and that I can then transform vectors by multiplying them with only its linear part (contrary to points). For normals finally, I should precompute the normal matrix as the transpose of the linear part's inverse. All those methods are easily available from the existing Eigen API, and it's great!

My issue is : I have an external constraint relative to the API I must comply to.
I can only handle Vector4f instances, while all computations involving my 3D affine transforms' linear parts must perform on Vector3f.

How can I initialize a Vector4f from a Vector3f as efficiently as possible (with 0 as its last component) ? I fear the impact of temporaries on the performance of my program...

Hope it makes some sense. I would appreciate any feedback. :)
Thanks a lot.
Pierre.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
If you use the Affine mode and not the CompactAffine mode, then you can also directly and efficiently deal with Vector4f:

Vector4f v1, v2;
Affine3f A;

v2 = A.linearExt() * v1.head<3>();

if that's too painful to write, you can wrap it in an inline function returning a Vector4f by value (no overhead because a Vector4f fit in a single register).

In the same vein, you could store the "normal" matrix in a Matrix4f padded with zeros:

Matrix4f B;
B << A.linear().inverse().transpose(), Vector3f::Zero(),
RowVector4f::Zero();


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]