I wanted to see DotProduct() Implementation, but I found only this:
can somebody explain how it equal a * b = ||a|| ||b|| cos(0)?
I wanted to see DotProduct() Implementation, but I found only this:
can somebody explain how it equal a * b = ||a|| ||b|| cos(0)?
Hi Levani
Here is a explanation of how they reached there (The proof section, case 1):
https://proofwiki.org/wiki/Cosine_Formula_for_Dot_Product
Thank you for answering Maxim, but as I remember from school there are two case of Vector’s scalar multiplies:
and in our case is used first version because we need angle, Is my view point right?
These are just two different ways of calculating dot product. I am sure that in unreal implementation
they used second one as it requires less computation.
If you are familiar with operator overloading then the answer is:
They overloaded | operator to be a dot product.
So probably implementation of operator | is something like following:
float operator|(const &FVector other) {
return (this.X * other.X) + (this.Y * otherY) + (this.Z * other.Z);
}
Update: Here is the actual code implementation by the way (Line 1279):
https://github.com/EpicGames/UnrealEngine/blob/dbced2dd59f9f5dfef1d7786fd67ad2970adf95f/Engine/Source/Runtime/Core/Public/Math/Vector.h
ahhhh I don’t think about this. It’s not binary operation it’s overload operator now its clear. Thank you Maxim