added some helper methods to VectorFloat

This commit is contained in:
hneemann 2018-04-15 10:08:16 +02:00
parent ea09282bc3
commit b4f8efaec2
2 changed files with 31 additions and 1 deletions

View File

@ -84,7 +84,7 @@ public class Polygon implements Iterable<VectorInterface> {
* @param p the end point to add * @param p the end point to add
* @return this for chained calls * @return this for chained calls
*/ */
public Polygon add(Vector c1, Vector c2, Vector p) { public Polygon add(VectorInterface c1, VectorInterface c2, VectorInterface p) {
isBezierStart.add(points.size()); isBezierStart.add(points.size());
points.add(c1); points.add(c1);
points.add(c2); points.add(c2);

View File

@ -51,6 +51,16 @@ public class VectorFloat implements VectorInterface {
return tr.transform(this); return tr.transform(this);
} }
/**
* Creates a new vector which has the value this+a
*
* @param a a
* @return this+a
*/
public VectorFloat add(VectorInterface a) {
return new VectorFloat(x + a.getXFloat(), y + a.getYFloat());
}
/** /**
* Subtracts the given vector * Subtracts the given vector
* *
@ -61,6 +71,26 @@ public class VectorFloat implements VectorInterface {
return new VectorFloat(x - sub.getXFloat(), y - sub.getYFloat()); return new VectorFloat(x - sub.getXFloat(), y - sub.getYFloat());
} }
/**
* Creates a new vector which has the value this*a
*
* @param a a
* @return this*a
*/
public VectorFloat mul(int a) {
return new VectorFloat(x * a, y * a);
}
/**
* Creates a new vector which has the value this/d
*
* @param d a
* @return this/d
*/
public VectorFloat div(int d) {
return new VectorFloat(x / d, y / d);
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;