001 package com.croftsoft.core.math; 002 003 import java.io.Serializable; 004 005 /********************************************************************* 006 * A mutable point in three-dimensional real space (x, y, and z). 007 * 008 * @version 009 * 2003-03-30 010 * @since 011 * 2002-02-06 012 * @author 013 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 014 * @deprecated 015 * Use Point3DD instead. 016 *********************************************************************/ 017 018 public final class Point3d 019 implements Cloneable, Serializable 020 ////////////////////////////////////////////////////////////////////// 021 ////////////////////////////////////////////////////////////////////// 022 { 023 024 private static final long serialVersionUID = 1L; 025 026 private double x; 027 028 private double y; 029 030 private double z; 031 032 ////////////////////////////////////////////////////////////////////// 033 ////////////////////////////////////////////////////////////////////// 034 035 public static boolean equivalent ( 036 Point3d aPoint3d, 037 Point3d bPoint3d ) 038 ////////////////////////////////////////////////////////////////////// 039 { 040 if ( aPoint3d == null ) 041 { 042 return bPoint3d == null; 043 } 044 else 045 { 046 return aPoint3d.equals ( bPoint3d ); 047 } 048 } 049 050 ////////////////////////////////////////////////////////////////////// 051 ////////////////////////////////////////////////////////////////////// 052 053 public Point3d ( 054 double x, 055 double y, 056 double z ) 057 ////////////////////////////////////////////////////////////////////// 058 { 059 this.x = x; 060 061 this.y = y; 062 063 this.z = z; 064 } 065 066 public Point3d ( ) 067 ////////////////////////////////////////////////////////////////////// 068 { 069 this ( 0.0, 0.0, 0.0 ); 070 } 071 072 ////////////////////////////////////////////////////////////////////// 073 ////////////////////////////////////////////////////////////////////// 074 075 public double getX ( ) { return x; } 076 077 public double getY ( ) { return y; } 078 079 public double getZ ( ) { return z; } 080 081 ////////////////////////////////////////////////////////////////////// 082 ////////////////////////////////////////////////////////////////////// 083 084 public void setX ( double x ) { this.x = x; } 085 086 public void setY ( double y ) { this.y = y; } 087 088 public void setZ ( double z ) { this.z = z; } 089 090 ////////////////////////////////////////////////////////////////////// 091 ////////////////////////////////////////////////////////////////////// 092 093 public boolean equals ( Object other ) 094 ////////////////////////////////////////////////////////////////////// 095 { 096 if ( other == null ) 097 { 098 return false; 099 } 100 101 if ( !this.getClass ( ).equals ( other.getClass ( ) ) ) 102 { 103 return false; 104 } 105 106 Point3d that = ( Point3d ) other; 107 108 return ( this.x == that.x ) 109 && ( this.y == that.y ) 110 && ( this.z == that.z ); 111 } 112 113 public int hashCode ( ) 114 ////////////////////////////////////////////////////////////////////// 115 { 116 // This might be a poor choice for a hash code algorithm. 117 118 return new Double ( x ).hashCode ( ) 119 ^ new Double ( y ).hashCode ( ) 120 ^ new Double ( z ).hashCode ( ); 121 } 122 123 public Object clone ( ) 124 ////////////////////////////////////////////////////////////////////// 125 { 126 try 127 { 128 return super.clone ( ); 129 } 130 catch ( CloneNotSupportedException ex ) 131 { 132 // This will never happen. 133 134 throw new RuntimeException ( ); 135 } 136 } 137 138 public String toString ( ) 139 ////////////////////////////////////////////////////////////////////// 140 { 141 return "<Point3d>" 142 + "<x>" + x + "</x>" 143 + "<y>" + y + "</y>" 144 + "<z>" + z + "</z>" 145 + "</Point3d>"; 146 } 147 148 ////////////////////////////////////////////////////////////////////// 149 ////////////////////////////////////////////////////////////////////// 150 }