package org.geogebra.common.awt; /** Class for integer tuples **/ public class GPointWithZ extends GPoint { public GPointWithZ() { z = 0; } public GPointWithZ(int x, int y, int z) { super(x, y); this.z = z; } /** z-coordinate **/ public int z = 0; /** * Set x and y at the same time * * @param x * x-coord * @param y * y-coord * @param z * z-coord */ public void setLocation(int x, int y, int z) { super.setLocation(x, y); this.z = z; } /** * Take both coords from a point * * @param p * point */ public void setLocation(GPointWithZ p) { super.setLocation(p); this.z = p.z; } @Override public int getZ() { return z; } @Override public int hashCode() { return (super.hashCode() << 16) ^ z; } @Override public boolean equals(Object o) { // super also check z-coord return super.equals(o); } public double distance(GPointWithZ d) { return Math.sqrt((x - d.x) * (x - d.x) + (y - d.y) * (y - d.y) + (z - d.z) * (z - d.z)); } public double distance(double dx, double dy, double dz) { return (int) Math.sqrt((x - dx) * (x - dx) + (y - dy) * (y - dy) + (z - dz) * (z - dz)); } @Override public String toString() { return x + " : " + y + " : " + z; } }