use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.
the class DroiteHorizontale method dessiner.
@Override
public void dessiner(@NotNull final Canvas toile, @NotNull final Repere repere) {
if (isVisible(toile, repere)) {
final double ordonneeVirtuelle = repere.ordonneeVirtuelle(getOrdonnee());
origineTrace = new Vector2D(0, ordonneeVirtuelle);
arriveeTrace = new Vector2D(toile.getWidth(), ordonneeVirtuelle);
dessinerContinue(toile.getGraphicsContext2D());
}
}
use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.
the class Etiquette method distance.
@Override
public double distance(@NotNull final Vector2D curseur, @NotNull final Repere repere) {
final Vector2D coinSuperieurGauche = repere.positionVirtuelle(getPositionAncrage()).add(getPositionRelative());
final Vector2D coinSuperieurDroit = coinSuperieurGauche.add(new Vector2D(getLargeur(), 0));
final Vector2D coinInferieurDroit = coinSuperieurDroit.add(new Vector2D(0, getHauteur()));
final Vector2D coinInferieurGauche = coinInferieurDroit.add(new Vector2D(-getLargeur(), 0));
if (curseur.getX() >= coinSuperieurGauche.getX() && curseur.getX() <= coinSuperieurDroit.getX() && curseur.getY() >= coinSuperieurDroit.getY() && curseur.getY() <= coinInferieurDroit.getY()) {
return 0;
}
return Math.min(new Segment(coinSuperieurGauche, coinSuperieurDroit, null).distance(curseur), Math.min(new Segment(coinSuperieurDroit, coinInferieurDroit, null).distance(curseur), Math.min(new Segment(coinInferieurDroit, coinInferieurGauche, null).distance(curseur), new Segment(coinInferieurGauche, coinSuperieurGauche, null).distance(curseur))));
}
use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.
the class RepereTest method testPositionVirtuelle.
@Test
public void testPositionVirtuelle() {
assertEquals(new Vector2D(500 - 2 * 50, 500 + 2 * 50), repere.positionVirtuelle(new Vector2D(-2, -2)));
assertEquals(new Vector2D(500 - 2 * 50, 500 + 50), repere.positionVirtuelle(new Vector2D(-2, -1)));
assertEquals(new Vector2D(500 - 50, 500 + 2 * 50), repere.positionVirtuelle(new Vector2D(-1, -2)));
assertEquals(new Vector2D(500 - 50, 500 + 50), repere.positionVirtuelle(new Vector2D(-1, -1)));
assertEquals(new Vector2D(500 - 50, 500), repere.positionVirtuelle(new Vector2D(-1, 0)));
assertEquals(new Vector2D(500, 500 + 50), repere.positionVirtuelle(new Vector2D(0, -1)));
assertEquals(new Vector2D(500, 500), repere.positionVirtuelle(new Vector2D(0, 0)));
assertEquals(new Vector2D(500, 500 - 50), repere.positionVirtuelle(new Vector2D(0, 1)));
assertEquals(new Vector2D(500 + 50, 500), repere.positionVirtuelle(new Vector2D(1, 0)));
assertEquals(new Vector2D(500 + 50, 500 - 50), repere.positionVirtuelle(new Vector2D(1, 1)));
assertEquals(new Vector2D(500 + 50, 500 - 2 * 50), repere.positionVirtuelle(new Vector2D(1, 2)));
assertEquals(new Vector2D(500 + 2 * 50, 500 - 50), repere.positionVirtuelle(new Vector2D(2, 1)));
assertEquals(new Vector2D(500 + 2 * 50, 500 - 2 * 50), repere.positionVirtuelle(new Vector2D(2, 2)));
}
use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.
the class RepereTest method initialiser.
@Before
public void initialiser() {
origineVirtuelle = new Vector2D(500, 500);
echelle = new Vector2D(50, 50);
repere = new Repere(origineVirtuelle, echelle);
}
use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project chordatlas by twak.
the class Concarnie method removeOverlaps.
private void removeOverlaps(List<Problem> current) {
Closer<Problem> closer = new Closer();
for (Problem a : current) {
try {
Region<Euclidean2D> ar = a.chull.createRegion();
b: for (Problem b : current) if (a != b)
for (Vector2D v : b.chull.getVertices()) {
Location vInA = ar.checkPoint(v);
if (vInA == Location.BOUNDARY || vInA == Location.INSIDE) {
closer.add(a, b);
continue b;
}
}
} catch (InsufficientDataException th) {
} catch (MathIllegalArgumentException th) {
}
}
for (Set<Problem> close : closer.close()) {
List<Problem> intersecting = new ArrayList<Problem>(close);
Collections.sort(intersecting, (a, b) -> -Double.compare(a.area(), b.area()));
for (int i = 1; i < intersecting.size(); i++) {
Problem togo = intersecting.get(i);
togo.addPortal();
current.remove(togo);
}
}
}
Aggregations