JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / src / javajs / util / P4.java
1 /*\r
2    Copyright (C) 1997,1998,1999\r
3    Kenji Hiranabe, Eiwa System Management, Inc.\r
4 \r
5    This program is free software.\r
6    Implemented by Kenji Hiranabe(hiranabe@esm.co.jp),\r
7    conforming to the Java(TM) 3D API specification by Sun Microsystems.\r
8 \r
9    Permission to use, copy, modify, distribute and sell this software\r
10    and its documentation for any purpose is hereby granted without fee,\r
11    provided that the above copyright notice appear in all copies and\r
12    that both that copyright notice and this permission notice appear\r
13    in supporting documentation. Kenji Hiranabe and Eiwa System Management,Inc.\r
14    makes no representations about the suitability of this software for any\r
15    purpose.  It is provided "AS IS" with NO WARRANTY.\r
16 */\r
17 package javajs.util;\r
18 \r
19 \r
20 \r
21 /**\r
22  * A 4 element point that is represented by single precision floating point\r
23  * x,y,z,w coordinates.\r
24  * \r
25  * @version specification 1.1, implementation $Revision: 1.9 $, $Date:\r
26  *          2006/07/28 17:01:32 $\r
27  * @author Kenji hiranabe\r
28  * \r
29  * additions by Bob Hanson hansonr@stolaf.edu 9/30/2012\r
30  * for unique constructor and method names\r
31  * for the optimization of compiled JavaScript using Java2Script\r
32  */\r
33 public class P4 extends T4 {\r
34 \r
35   /**\r
36    * \r
37    * @j2sIgnore   * \r
38    */\r
39   public P4() {\r
40     // skip T4() constructor\r
41   }\r
42   \r
43   public static P4 new4(float x, float y, float z, float w) {\r
44     P4 pt = new P4();\r
45     pt.set4(x, y, z, w);\r
46     return pt;\r
47   }\r
48 \r
49   public static P4 newPt(P4 value) {\r
50     P4 pt = new P4();\r
51     pt.set4(value.x, value.y, value.z, value.w);    \r
52     return pt;\r
53   }\r
54 \r
55   /**\r
56    * Returns the distance between this point and point p1.\r
57    * \r
58    * @param p1\r
59    *        the other point\r
60    * @return the distance between these two points\r
61    */\r
62   public final float distance4(P4 p1) {\r
63     double dx = x - p1.x;\r
64     double dy = y - p1.y;\r
65     double dz = z - p1.z;\r
66     double dw = w - p1.w;\r
67     return (float) Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw);\r
68   }\r
69 \r
70 }\r