point.js revision 877:cf4d2252d444
1169691Skan/* 2169691Skan * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 3169691Skan * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4169691Skan * 5169691Skan * This code is free software; you can redistribute it and/or modify it 6169691Skan * under the terms of the GNU General Public License version 2 only, as 7169691Skan * published by the Free Software Foundation. 8169691Skan * 9169691Skan * This code is distributed in the hope that it will be useful, but WITHOUT 10169691Skan * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11169691Skan * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12169691Skan * version 2 for more details (a copy is included in the LICENSE file that 13169691Skan * accompanied this code). 14169691Skan * 15169691Skan * You should have received a copy of the GNU General Public License version 16169691Skan * 2 along with this work; if not, write to the Free Software Foundation, 17169691Skan * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18169691Skan * 19169691Skan * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20169691Skan * or visit www.oracle.com if you need additional information or have any 21169691Skan * questions. 22169691Skan */ 23169691Skan 24169691Skan 25169691Skan/** 26169691Skan * @subtest 27169691Skan */ 28169691Skan 29169691Skanfunction Point(x, y) { 30169691Skan this.x =x; this.y =y; 31169691Skan} 32169691Skan 33169691SkanPoint.prototype.toString = function() { 34169691Skan return "(" + this.x + "," + this.y + ")"; 35169691Skan} 36169691Skan 37169691SkanPoint.prototype.modulus = function() { 38169691Skan return Math.sqrt(this.x*this.x + this.y*this.y); 39169691Skan} 40169691Skan 41169691SkanPoint.prototype.argument = function() { 42169691Skan return Math.atan2(this.y, this.x); 43169691Skan} 44169691Skan 45169691Skanload(__DIR__ + "maputil.js"); 46169691Skan 47169691SkanassertSameMap(new Point(2, 3), new Point(43, 23)); 48169691SkanassertSameMap(new Point(), new Point()); 49169691SkanassertEqualWithoutTypeMap(new Point(), new Point(3, 1)); 50169691Skan