2 * $RCSfile: Point3d.java,v $
4 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation. Sun designates this
10 * particular file as subject to the "Classpath" exception as provided
11 * by Sun in the LICENSE file that accompanied this code.
13 * This code is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * version 2 for more details (a copy is included in the LICENSE file that
17 * accompanied this code).
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24 * CA 95054 USA or visit www.sun.com if you need additional information or
28 * $Date: 2008/02/28 20:18:50 $
32 package javax.vecmath;
34 import java.lang.Math;
37 * A 3 element point that is represented by double precision floating point
41 public class Point3d extends Tuple3d implements java.io.Serializable {
43 // Compatible with 1.1
44 static final long serialVersionUID = 5718062286069042927L;
47 * Constructs and initializes a Point3d from the specified xyz coordinates.
48 * @param x the x coordinate
49 * @param y the y coordinate
50 * @param z the z coordinate
52 public Point3d(double x, double y, double z)
59 * Constructs and initializes a Point3d from the array of length 3.
60 * @param p the array of length 3 containing xyz in order
62 public Point3d(double[] p)
69 * Constructs and initializes a Point3d from the specified Point3d.
70 * @param p1 the Point3d containing the initialization x y z data
72 public Point3d(Point3d p1)
79 * Constructs and initializes a Point3d from the specified Point3f.
80 * @param p1 the Point3f containing the initialization x y z data
82 public Point3d(Point3f p1)
89 * Constructs and initializes a Point3d from the specified Tuple3f.
90 * @param t1 the Tuple3f containing the initialization x y z data
92 public Point3d(Tuple3f t1)
99 * Constructs and initializes a Point3d from the specified Tuple3d.
100 * @param t1 the Tuple3d containing the initialization x y z data
102 public Point3d(Tuple3d t1)
109 * Constructs and initializes a Point3d to (0,0,0).
118 * Returns the square of the distance between this point and point p1.
119 * @param p1 the other point
120 * @return the square of the distance
122 public final double distanceSquared(Point3d p1)
129 return (dx*dx+dy*dy+dz*dz);
134 * Returns the distance between this point and point p1.
135 * @param p1 the other point
136 * @return the distance
138 public final double distance(Point3d p1)
145 return Math.sqrt(dx*dx+dy*dy+dz*dz);
150 * Computes the L-1 (Manhattan) distance between this point and
151 * point p1. The L-1 distance is equal to:
152 * abs(x1-x2) + abs(y1-y2) + abs(z1-z2).
153 * @param p1 the other point
154 * @return the L-1 distance
156 public final double distanceL1(Point3d p1) {
157 return Math.abs(this.x-p1.x) + Math.abs(this.y-p1.y) +
158 Math.abs(this.z-p1.z);
163 * Computes the L-infinite distance between this point and
164 * point p1. The L-infinite distance is equal to
165 * MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)].
166 * @param p1 the other point
167 * @return the L-infinite distance
169 public final double distanceLinf(Point3d p1) {
171 tmp = Math.max( Math.abs(this.x-p1.x), Math.abs(this.y-p1.y));
173 return Math.max(tmp,Math.abs(this.z-p1.z));
178 * Multiplies each of the x,y,z components of the Point4d parameter
179 * by 1/w and places the projected values into this point.
180 * @param p1 the source Point4d, which is not modified
182 public final void project(Point4d p1)