mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-11 22:07:37 -04:00
added some helper methods to VectorFloat
This commit is contained in:
parent
ea09282bc3
commit
b4f8efaec2
@ -84,7 +84,7 @@ public class Polygon implements Iterable<VectorInterface> {
|
||||
* @param p the end point to add
|
||||
* @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());
|
||||
points.add(c1);
|
||||
points.add(c2);
|
||||
|
@ -51,6 +51,16 @@ public class VectorFloat implements VectorInterface {
|
||||
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
|
||||
*
|
||||
@ -61,6 +71,26 @@ public class VectorFloat implements VectorInterface {
|
||||
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
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user