Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 Alexander Kerner. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 package net.sf.kerner.utils.math;

A Point in a two-dimensional coordinate system, defined by double Coordinates.

Example:

 TODO example
 

Deprecated:
Use Point2D instead
Author(s):
Alexander Kerner
Version:
2011-03-01
 
 public class Point {
 
 	private final double x;
 
 	private final double y;

Create a new Point, at given X- and Y-Coordinate.

Parameters:
x X-Coordinate
y Y-Coordinate
 
 	public Point(double xdouble y) {
 		this. = y;
 		this. = x;
 	}

Create new Point, which is a copy of given Point

Parameters:
template Point to copy
 
 	public Point(Point template) {
 		this(template.xtemplate.y);
 	}

Calculate the slope from one Point to another.

Parameters:
one first Point
tow second Point
Returns:
the slope
 
 	final public static double getSlope(Point onePoint tow) {
 		final double b = getDeltaX(onetow);
 		if (b == 0)
 			return 0;
 		return getDeltaY(onetow) / (b);
 	}
 
 	final static double getDeltaY(Point onePoint two) {
 		return two.y - one.y;
 	}
 
 	final static double getDeltaX(Point onePoint two) {
 		return two.x - one.x;
 	}
 
 	final public double getDistance(Point two) {
 		return Math.sqrt(Math.pow(Point.getDeltaX(thistwo), 2) + Math.pow(Point.getDeltaY(thistwo), 2));
	}
	final public double getSlope(Point two) {
		return Point.getSlope(thistwo);
	}
	public double getX() {
		return ;
	}
	public double getY() {
		return ;
	}
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits();
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits();
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Point)) {
			return false;
		}
		Point other = (Pointobj;
		if (Double.doubleToLongBits() != Double.doubleToLongBits(other.x)) {
			return false;
		}
		if (Double.doubleToLongBits() != Double.doubleToLongBits(other.y)) {
			return false;
		}
		return true;
	}
	public String toString() {
		return "[x=" +  + ",y=" +  + "]";
	}
New to GrepCode? Check out our FAQ X