Vector multiplication

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Vector multiplication

Postby misho » Sat May 19, 2018 12:23 pm

I was wondering (just out of curiosity) what kind of a vector operation is the following:

Code: Select all
template<class T>
TemplateVector<T> TemplateVector<T>::operator* (const TemplateVector<T>& B) const
{
   return TemplateVector<T>(m_x * B.m_x, m_y * B.m_y, m_z * B.m_z, m_w);
}


It is not any of the four classes of vector multiplication, as defined in the Wiki article...

So, what is it, and where is it used?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Vector multiplication

Postby Dave Gravel » Sat May 19, 2018 2:08 pm

It look like a simple VectorScale.
It is used for many situations.
You can find float & affine version or hmg with the W multiplication too.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Vector multiplication

Postby misho » Sat May 19, 2018 2:21 pm

Dave Gravel wrote:It look like a simple VectorScale.
It is used for many situations.
You can find float & affine version or hmg with the W multiplication too.


Thanks... but this is simple scaling:

Code: Select all
template<class T>
TemplateVector<T> TemplateVector<T>::Scale (T scale) const
{
   return TemplateVector<T> (m_x * scale, m_y * scale, m_z * scale, m_w);
}


Searching (briefly) online, I was unable to find any use for the "*" operator. I'd be grateful if you can point me to a reference.

Thanks!
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Vector multiplication

Postby Dave Gravel » Sat May 19, 2018 2:37 pm

Maybe my english is to bad for explain right.
Both is the same, In the first it use a Vector for scale a other vector.
In the second it use a Float to scale a vector.

first

vector v1,v2;

v1.x * v2.x, v1.y * v2.y....

two

float scalefactor;
vector v1;

v1.x * scalefactor, v1.y * scalefactor ....

Edit: You can use it for graphics or exemple scale a force vector or many things.

Both do the same thing.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Vector multiplication

Postby misho » Sat May 19, 2018 2:50 pm

Dave Gravel wrote:Both do the same thing.


Thanks...but your English is fine :wink:

These two operations do NOT do the same thing. First operation will give you a scaled vector in the same direction as the original.

Code: Select all
[1,2,3] * 3 = [3,6,9]


Second one won't:

Code: Select all
[1,2,3] * [4,5,6] = [4,10,18]

unless your vector's parameters are identical:
[1,2,3] * [3,3,3] = [3,6,9]


:roll:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Vector multiplication

Postby Dave Gravel » Sat May 19, 2018 2:54 pm

Yes it's not exactly the same result for sure hehe.
Exemple with the vector version you can scale a force in the desired direction..
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Vector multiplication

Postby misho » Sat May 19, 2018 3:07 pm

Well, sure, you can do a lot of things with it, but compared to other "usual" vector operators, this seems a bit arbitrary and vague. And, to the point, it is not listed as a vector math operation anywhere, it just seems to be a "helper" function... :wink:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Vector multiplication

Postby JoeJ » Sat May 19, 2018 4:49 pm

I think we oftencall this a component wise multiplication - at least i do so.

It makes sense for example when working with colors like outGoingLight = inComingLight.CompMul(surfaceColor)

Or a nonuniform scale like scaledPos = pos.CompMul(nonuniformScale)

...


Julio is a very bad guy. :mrgreen: Again he enjoys to confuse us with conventions usual to mathematicans, but very unusual for game devs. I assume almost everybody uses the * operator for multiplication by scalar, and a function name for multiplication by vector. :roll:
Luckily this time wrongly intended code does not compile 8)
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Vector multiplication

Postby misho » Sat May 19, 2018 7:08 pm

JoeJ wrote:Julio is a very bad guy. :mrgreen: Again he enjoys to confuse us with conventions usual to mathematicans, but very unusual for game devs. I assume almost everybody uses the * operator for multiplication by scalar, and a function name for multiplication by vector. :roll:
Luckily this time wrongly intended code does not compile 8)


LOL Ok, so you see it too! :mrgreen: That's what I was getting at, it is a very unusual way of designating a rather obvious math operator that actually does something that's not usually done in vector math :wink:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 20 guests

cron