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