[math-utils] should Vector2 math functions modify this
or return a copy?
#7553
miltoncandelero
started this conversation in
RFC
Replies: 1 comment 4 replies
-
Can we go both? Just pass an optional last argument to every function.
I have seen this in a couple of vector math libs |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Among other things,
@pixi/math-utils
will include some vector math operations that will be mixed insidePoint
so you will be able to do something likemyPoint.addition(anotherPoint)
and get the vectorial sum of both Points.Currently the functions are:
addition(other: Point): Point;
&subtraction(other: Point): Point;
multiplication(other: Point): Point;
&division(other: Point): Point;
scalarMultiplication(number: number): Point;
dotProduct(other: Point): number;
crossProduct(other: Point): number;
normalized(): Point;
magnitude(): number;
&magnitudeSquared(): number;
project(other: Point): Point;
reflect(normal: Point): Point;
equals(other: Point): boolean;
distance(other: Point): number;
Some of them have a result of another Point. The issue is:
Should these methods modify
this
vector (in-place operation)?- or -
Should they always return a
new Point
?Precedence:
clone
first if you need a copy.Beta Was this translation helpful? Give feedback.
All reactions