]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.datatypes/src/org/simantics/datatypes/literal/Vec2i.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.datatypes / src / org / simantics / datatypes / literal / Vec2i.java
1 package org.simantics.datatypes.literal;
2
3 import org.simantics.databoard.Bindings;
4 import org.simantics.databoard.binding.Binding;
5 import org.simantics.databoard.util.Bean;
6
7
8 final public class Vec2i extends Bean {
9
10         public static final Binding BINDING = Bindings.getBindingUnchecked(Vec2i.class);
11
12         public int x;
13         public int y;
14
15         public Vec2i(int x, int y) {
16                 super(BINDING);
17                 this.x = x;
18                 this.y = y;
19         }
20
21         public boolean isZero() {
22                 return x==0 && y==0; 
23         }
24         
25         public double norm1() {
26                 return Math.abs(x) + Math.abs(y);
27         }
28         
29         public double norm2() {
30                 return Math.sqrt(x*x+y*y);
31         }
32         
33         public double length() {
34                 return norm2();
35         }
36         
37         public double dot(Vec2i other) {
38                 return x*other.x + y*other.y;
39         }
40
41         public Vec2i sum(Vec2i other) {
42                 return new Vec2i(x + other.x , y + other.y);
43         }
44
45         @Override
46         public String toString() {
47                 return "Vec2i[x=" + x + ", y=" + y + "]";
48         }
49         
50 }