# Source code for Point.java

What follows is the highlighted source code with comments. You can also download this file directly: Point.java.

```/*
* This work by W. Patrick Hooper is free of known copyright restrictions.
* The work is in the public domain.
*
* Author's website: <a href="http://wphooper.com">http://wphooper.com</a>.
*/

package projectiveplane;

/**
* This class represents a point in the real projective plane.
*
* @author W. Patrick Hooper <wphooper@gmail.com>
* @version 1
*/
public class Point {
/** The following array stores the homogeneous coordinates for the point. */
double[] c=new double;

public Point(){
c=c=0;
c=1;
}

public Point(double x, double y){
c=x;
c=y;
c=1;
}

// Given in Projective coordinates
public Point(double x, double y, double z){
c=x;
c=y;
c=z;
}

// Given in Projective coordinates given by an array
public Point(double[] x){
c=x;
c=x;
c=x;
}

public Point(Point P){
double d[]=P.getProjectiveCoordinates();
c=d;
c=d;
c=d;
}

public double distanceSquared(Point P){
return
((getX()-P.getX())*(getX()-P.getX())+
(getY()-P.getY())*(getY()-P.getY()));
}

public boolean isNotInfinite(){
return (c!=0);
}

public boolean isInfinite(){
return (c==0);
}

public double getX(){
return (c/c);
}

public double getY(){
return (c/c);
}

public double[] getProjectiveCoordinates(){
return c;
}

public String toString(){
return "("+
Double.toString(c)+":"+
Double.toString(c)+":"+
Double.toString(c)+")";
}

}

```
HOOPER >>>>> JAVA TUTORIAL