Can you divide vectors in Haxe like this?

question
#1

Say I have two vectors, v and v2. I see elsewhere that I can multiply them together in Haxe like so:

v.x *= v2.x;
v.y *= v2.y;
v.z *= v2.z;

But can you similarly divide one vector by another like this?

v.x /= v2.x;
v.y /= v2.y;
v.z /= v2.z;
0 Likes

#2

That depends on whether the vector implementation implements the operator. Haxe’s operator overloading does support both in principle.

0 Likes

#3

Armory’s vector classes don’t have the operator overloading so that you can use the *= or /= operators on them. It looks like there isn’t a divide function in Armory’s Vector class either.

0 Likes

#4

Mr Blob multiplies element by element so this doesn’t require operator overloading and consequently the answer is: Yes.

0 Likes

#5

Ah, should’ve paid more attention to the code example than the question. He isn’t actually dividing vectors there. :slight_smile:

1 Like

#6

:man_facepalming: Yep, that’s right. :smile:

0 Likes