-
Notifications
You must be signed in to change notification settings - Fork 13
/
KMetagonVector.java
62 lines (46 loc) · 1.63 KB
/
KMetagonVector.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package org.fleen.geom_Kisrhombille;
import java.io.Serializable;
/*
* Vector used in general polygon model
* direction is integer in range [-5,5]. It describes a direction relative to another direction, 0 being equal.
* relativeinterval is double. It describes an interval in terms of a base interval.
*/
public class KMetagonVector implements Serializable{
private static final long serialVersionUID=1794434316990821717L;
public int directiondelta;
public double relativeinterval;
/*
* ################################
* CONSTRUCTORS
* ################################
*/
public KMetagonVector(int directiondelta,double relativeinterval){
this.directiondelta=directiondelta;
this.relativeinterval=relativeinterval;}
public KMetagonVector(){}
/*
* ################################
* OBJECT
* ################################
*/
private static final double RELATIVEINTERVALEQUALITYERROR=0.000001;
public boolean equals(Object a){
KMetagonVector b=(KMetagonVector)a;
boolean e=directiondelta==b.directiondelta;
if(!e)return false;
e=equals(relativeinterval,b.relativeinterval,RELATIVEINTERVALEQUALITYERROR);
return e;}
//simplistic, yes. we eschew employing floats etc
public int hashCode(){
return directiondelta*7919;}
public String toString(){
String s="["+directiondelta+","+relativeinterval+"]";
return s;}
public Object clone(){
return new KMetagonVector(directiondelta,relativeinterval);}
private boolean equals(double a,double b,double error){
if(a<b){
return b-a<error;
}else{
return a-b<error;}}
}