Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Point.java 1.24 KiB
package object_detection;

public class Point {

    // index
    static int count = 0;

    // members
    private float x;
    private float y;
    private float z;
    final int idx;

    // METHODS

    /*
    Object Constructor of a feature in 3D
     */
    public Point(float xx, float yy, float zz){
        this.x = xx;
        this.y = yy;
        this.z = zz;
        this.idx = count++;
    }

    /**
     * helper function for equals overriding
     * @param aa : first point
     * @param bb : second point
     * @param err : error between aa and bb that is acceptable
     * @return true if points are close enough
     */
    public static boolean equals(Point aa, Point bb, float err){
        return (aa.x - bb.x < err) && (aa.y - bb.y < err) && (aa.z - bb.z < err);
    }

    @Override
    public boolean equals(Object o){
        if(getClass() != o.getClass()){
            return false;
        }
        Point p = (Point) o;
        return Point.equals(this, p, (float) 0.05);
    }

    @Override
    public int hashCode() {
        float res = this.x + this.y + this.z;
        return Float.hashCode(res);
    }
    @Override
    public String toString() {
        return "Point(" + this.x + " ," + this.y + " ," + this.z + ")";
    }

}