File: XYpoint.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (43 lines) | stat: -rw-r--r-- 856 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package tim.prune.function.compress;

/**
 * Basic class to hold x and y coordinates
 * for a point or a vector
 */
public class XYpoint
{
	// x and y coordinates
	public final double x, y;

	/**
	 * Constructor
	 * @param inX x value
	 * @param inY y value
	 */
	public XYpoint(double inX, double inY) {
		x = inX;
		y = inY;
	}

	/**
	 * @param inOther other vector
	 * @return scalar dot product
	 */
	public double dot(XYpoint inOther) {
		return (x * inOther.x + y * inOther.y);
	}

	/** @return length of vector */
	public double len() {return Math.sqrt(len2());}

	/** @return squared length of vector */
	public double len2() {return (x*x + y*y);}

	/**
	 * @param inOther other point object
	 * @return vector from this one to the other one
	 */
	public XYpoint vectorTo(XYpoint inOther) {
		return new XYpoint(inOther.x - x, inOther.y - y);
	}
}