Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Coord2D(X, Y) {
- var _this = this;
- (function() {
- _this.X = X || 0;
- _this.Y = Y || 0;
- })();
- // Retourne la distance entre 2 points
- this.getDistance = function(coordTo) {
- return Math.pow(_this.X - coordTo.X, 2) + Math.pow(_this.Y - coordTo.Y, 2);
- };
- }
- var pointA = new Coord2D();
- var pointB = new Coord2D(2, 2);
- var dist = pointA.getDistance(pointB);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement