Point3D.java
Go to the documentation of this file.00001 package theba.core.math;
00002
00003 import theba.core.LumenCandidate;
00004
00011 public class Point3D {
00012 public int x, y, z;
00013
00014 public Point3D(int x, int y, int z) {
00015 this.x = x;
00016 this.y = y;
00017 this.z = z;
00018 }
00019
00020 public Point3D(LumenCandidate lc){
00021 this.x = lc.x;
00022 this.y = lc.y;
00023 this.z = lc.z;
00024 }
00028 @Override
00029 public String toString() {
00030 return "x :" + x + " y:" + y + " z:" + z;
00031 }
00032
00036 public double distanceFrom(Point3D p2) {
00037 double a = x - p2.x;
00038 double b = y - p2.y;
00039 double c = z - p2.z;
00040
00041 return (Math.sqrt(a * a + b * b + c * c));
00042 }
00043
00047 public void normalize() {
00048 double length = distanceFrom(new Point3D(0, 0, 0));
00049 x /= length;
00050 y /= length;
00051 z /= length;
00052 }
00053 }