Open trych opened 6 years ago
This is correct and IMO from the API design point identical to p5 and Processing.
var a = new Vector(1,1,1); // or use createVector() var b = new Vector(2,2,2);
var d = a.dist(b); // or written in a different style var d = Vector.dist(a, b);
We simply give the users the option to write the same operation in two different ways. Both are fine and is a matter of how you think about vectors. I would vote to leave it as it is.
RE: what is a static method? Please google something like "what is a static method in java” … basically: static = every instance of the class share a single identical “static” method
Ah, okay, I get it now. Then I am just confused about the documentation. We should probably have that only in one place and then give examples for both syntax variants, right? @fabianmoronzirfas
We have the methods Vector.dist(), Vector.cross() and Vector.dot() twice in our code.
I think this is intentional, however, can someone help me understand how this works?
Example dist:
We once have it as a method of the Vector prototype:
and then we have it as a Vector method, outside the prototype thing:
@basiljs For the second version it says, it is a "static function" (quote: "Is meant to be called "static" i.e.
Vector.dist(v1, v2);
"). I don't know what that means. What is a static method?Also, I guess the second version does not overwrite the first version, right? I guess it extends it somehow? Is the first version supposed to be private?
Also, I think this turns into a problem that the inline docs of one version are overwriting the other one. How should we handle that? Should we rename one of them?