I hope I understood your question correctly. Most of the time you’ll only need 3d vectors, as most of the time you know it’s type: a point (w=1) or normal (w=0). Only in special parts of your code you might require 4d vectors, but rarely. Most of the time it is a waste of space to store w and most of the time it is a waste of time to matrix multiply with w if it is 1 or 0. At least that is my experience, I’m a humble hobby-coder :)

Hi,

when you implement your vector math library do you use ordinary 3D vector or 4D homogenous vector? Or both?

I mean in general case.

If I had 3D vector I’d supply w-coordinate when I need it.

However, if I had 4D vector, how would I compute vector operations (dot product, cross product and so on)? Like 3D and keep w on some value (1 or 0?)?

Or compute in 4D? But in this case, can I make cross product in 4D?

Or do you make both classes? In this case, API would be messy(somewhere 3D vector, somewhere 4D vector,…), wouldn’t it?

I hope that I’ve explained my question in understandable way:-)

Thank you for any advise!