DX11 - API - Disadvantage of vector multiplication.

Started by
8 comments, last by Pink Horror 10 years, 7 months ago

Hi guys, wink.png

some few times multiplying vectors of same kind becomes a must, and so I do it, but I need to do multiply the components individually (Not a problem). But the class D3DVECTORX (2, 3, 4...), doesn't have an multiply operator with an overload for other vectors of it's kind, why not?

Why has the developers chosen that? ( Disadvantages ? )

Thanks, as usual.

-MIGI0027

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

Advertisement

Probably because it can be confused with a dot product, which also takes two vectors as arguments. E.g. I use SlimDX and the math library there doesn't even have such an overload, but explicitly named functions for both dot and a so-called modulate. Counter example: HLSL uses modulate for *, but has an intrinsic for dot (or mul for matrix vector multiplication).

If you don't find such a modulate function, it should be easy write a free function :wink:

Thanks unbird, just what I needed to hear. wink.png

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

It is likely because multiplying one vector by another component wise doesn't make sense as an operation on vector spaces. Under what circumstances do you need to use component wise multiplication?

I'm trying to implement Volume Rendering,

link can be found here: http://www.gamedev.net/topic/647531-dx11-volume-rendering-article-misunderstanding/

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

It is likely because multiplying one vector by another component wise doesn't make sense as an operation on vector spaces. Under what circumstances do you need to use component wise multiplication?

Sure it does, its just a non-uniform scale. Granted its not the most common operation for 3D graphics, but its hardly unheard of, and it has wide applicability in other domains. In my own vector math library, I overload operator * and operator / between vectors to mean piecewise multiplication and piecewise division (non-uniform scaling), and between vectors and scalars by extending the scalar to a vector of same rank (uniform scaling). I feel that this configuration best satisfies the recommended design principles of "principle of least surprise" (particularly regarding operator associativity and operator precedense) and "do as the ints do". I provide for the dot, cross (and 2D psuedo-cross) product as (non-member) functions, along with some other useful ones. I'm pretty happy with how orthogonal this makes things, and while its not as terse as with operator overloading, it forces you to state the order of operations explicitly.

throw table_exception("(? ???)? ? ???");

It is likely because multiplying one vector by another component wise doesn't make sense as an operation on vector spaces. Under what circumstances do you need to use component wise multiplication?

Sure it does, its just a non-uniform scale. Granted its not the most common operation for 3D graphics, but its hardly unheard of, and it has wide applicability in other domains. In my own vector math library, I overload operator * and operator / between vectors to mean piecewise multiplication and piecewise division (non-uniform scaling), and between vectors and scalars by extending the scalar to a vector of same rank (uniform scaling). I feel that this configuration best satisfies the recommended design principles of "principle of least surprise" (particularly regarding operator associativity and operator precedense) and "do as the ints do". I provide for the dot, cross (and 2D psuedo-cross) product as (non-member) functions, along with some other useful ones. I'm pretty happy with how orthogonal this makes things, and while its not as terse as with operator overloading, it forces you to state the order of operations explicitly.

I think we have differing definitions of vectors.

Not really. Strictly speaking, I suppose non-uniform-scaling isn't common in processing things like geometry, but it certainly has a meaning that's rational enough to be useful, and vectors and vector spaces have other applications. For example, if you consider a color space (like RGB), as a vector space, then operations like gamma-correction are just non-uniform scales. We can argue mathematical pedantries all day but when we're being pragmatic there's not a strong argument to be made for keeping to a 100% correct, mathematical definition of vectors intact (unless you're specifically working in a pure-math domain, and want the type system to chain you to the mathematical definition intentionally). For example, even though vectors and points are entirely different mathematical concepts, they can be represented in unified form, and often are, without making any dangerous compromises.

throw table_exception("(? ???)? ? ???");

It is likely because multiplying one vector by another component wise doesn't make sense as an operation on vector spaces. Under what circumstances do you need to use component wise multiplication?

Sure it does, its just a non-uniform scale. Granted its not the most common operation for 3D graphics, but its hardly unheard of, and it has wide applicability in other domains. In my own vector math library, I overload operator * and operator / between vectors to mean piecewise multiplication and piecewise division (non-uniform scaling), and between vectors and scalars by extending the scalar to a vector of same rank (uniform scaling). I feel that this configuration best satisfies the recommended design principles of "principle of least surprise" (particularly regarding operator associativity and operator precedense) and "do as the ints do". I provide for the dot, cross (and 2D psuedo-cross) product as (non-member) functions, along with some other useful ones. I'm pretty happy with how orthogonal this makes things, and while its not as terse as with operator overloading, it forces you to state the order of operations explicitly.

I think we have differing definitions of vectors.

Are you implying that a useful construct for computer graphics (non-uniform scaling, which is used in editors all the time) should not be allowed because of the mathematical definition of a vector? Non-uniform scaling is very clearly used frequently - are you saying that such an operation should not be possible?

I just don't see the logic in the argument you are making here...


some few times multiplying vectors of same kind becomes a must, and so I do it, but I need to do multiply the components individually (Not a problem). But the class D3DVECTORX (2, 3, 4...), doesn't have an multiply operator with an overload for other vectors of it's kind, why not?

Why are you asking about D3DVECTOR structs in a topic titled with "DX11"? DirectX 11 has DirectXMath, which has the XMVECTOR class, which has an operator for component multiplication.

This topic is closed to new replies.

Advertisement