1 package org.simantics.datatypes.literal;
3 import org.simantics.databoard.Bindings;
4 import org.simantics.databoard.binding.Binding;
5 import org.simantics.databoard.util.Bean;
8 final public class Vec2d extends Bean {
10 public static final Binding BINDING = Bindings.getBindingUnchecked(Vec2d.class);
15 public Vec2d(double x, double y) {
21 public boolean isZero() {
22 return x==0.0 && y==0.0;
25 public double norm1() {
26 return Math.abs(x) + Math.abs(y);
29 public double norm2() {
30 return Math.sqrt(x*x+y*y);
33 public double length() {
37 public double dot(Vec2d other) {
38 return x*other.x + y*other.y;
41 public Vec2d sum(Vec2d other) {
42 return new Vec2d(x + other.x , y + other.y);
45 public Vec2d subtraction(Vec2d other) {
46 return new Vec2d(x - other.x , y - other.y);
50 public String toString() {
51 return "Vec2d[x=" + x + ", y=" + y + "]";