mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-12 14:26:09 -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
|
* @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);
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user