I have noticed in other languages such as Java that there are Objects such as Vector2d that have a multiply method. How would I do the same with Actionscript 3? I know that the Point or Vector3D classes have add/substract methods, but neither offer multiply/divide methods.
What is the best way to multiply two Point objects? would it be something like the following?
var p1:Point = new Point(10, 20);
var p2:Point = new Point(30, 40);
var p3:Point = new Point((p1.x * p2.x), (p1.y * p2.y));
Also why would multiply/divide be left out of these classes?
EDIT* Here is a link to the Vector2d class I have seen in Java: Java Vector2d multiply
What would be the mathematical meaning of
new Point((p1.x * p2.x), (p1.y * p2.y))? In a vector space, there is usually no multiplication, as it is simply not clear, what it should do.However, there is a so called “scalar multiplication” defined on the vectors of the euclidean space, which yields a number (“scalar”, hence the name):
This is useful, for example, if you need to test, whether to lines are orthogonal. However, the result is a number not a vector.
Another thing to do with vectors is to scale them:
Here the result is indeed a point, but the input is a number and a vector, not two vectors. So, unless you can say, what the interpretation/meaning of your vector multiplication is, you shouldn’t define one. (Note, that I don’t know, whether your proposal might be useful or not — it is simply not a “standard” multiplication I know of).