📄 point3di.java
字号:
package com.croftsoft.core.math.geom;
import java.io.Serializable;
/*********************************************************************
* A mutable point in three-dimensional integer space (x, y, and z).
*
* @version
* 2003-04-15
* @since
* 2001-03-07
* @author
* <a href="http://www.croftsoft.com/">David Wallace Croft</a>
*********************************************************************/
public final class Point3DI
implements Cloneable, Serializable
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
{
private static final long serialVersionUID = 0L; //
private int x;
private int y;
private int z;
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public static boolean equivalent (
Point3DI aPoint3DI,
Point3DI bPoint3DI )
//////////////////////////////////////////////////////////////////////
{
if ( aPoint3DI == null )
{
return bPoint3DI == null;
}
else
{
return aPoint3DI.equals ( bPoint3DI );
}
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public Point3DI (
int x,
int y,
int z )
//////////////////////////////////////////////////////////////////////
{
this.x = x;
this.y = y;
this.z = z;
}
public Point3DI ( )
//////////////////////////////////////////////////////////////////////
{
this ( 0, 0, 0 );
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public int getX ( ) { return x; }
public int getY ( ) { return y; }
public int getZ ( ) { return z; }
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public void setX ( int x ) { this.x = x; }
public void setY ( int y ) { this.y = y; }
public void setZ ( int z ) { this.z = z; }
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public boolean equals ( Object other )
//////////////////////////////////////////////////////////////////////
{
if ( other == null )
{
return false;
}
if ( !this.getClass ( ).equals ( other.getClass ( ) ) )
{
return false;
}
Point3DI that = ( Point3DI ) other;
return ( this.x == that.x )
&& ( this.y == that.y )
&& ( this.z == that.z );
}
public int hashCode ( )
//////////////////////////////////////////////////////////////////////
{
// This might be a poor choice for a hash code algorithm.
return x ^ y ^ z;
}
public Object clone ( )
//////////////////////////////////////////////////////////////////////
{
try
{
return super.clone ( );
}
catch ( CloneNotSupportedException ex )
{
// This will never happen.
throw new RuntimeException ( );
}
}
public String toString ( )
//////////////////////////////////////////////////////////////////////
{
return "<Point3DI>"
+ "<x>" + x + "</x>"
+ "<y>" + y + "</y>"
+ "<z>" + z + "</z>"
+ "</Point3DI>";
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -