Jump to content
  • Advertisement
Sign in to follow this  
Migi0027

DX11 DX11 - API - Disadvantage of vector multiplication.

This topic is 1779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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:

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

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.

Edited by Ravyne

Share this post


Link to post
Share on other sites

 

 

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...

Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!