Search in sources :

Example 1 with Vector2D

use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.

the class EspaceInteractif method deplacer.

/**
 * Déplace l'espace de la toile selon la variation des positions du curseur.
 *
 * @param positionCurseur la position virtuelle actuelle du curseur.
 * @see EspaceInteractif#positionPrecendenteCurseur
 */
private void deplacer(@NotNull final Vector2D positionCurseur) {
    final Vector2D deplacement = positionCurseur.subtract(positionPrecendenteCurseur);
    final Vector2D nouvelleOrigine = repere.getOrigineVirtuelle().add(deplacement);
    repere.setOrigineVirtuelle(new Vector2D((int) nouvelleOrigine.getX(), (int) nouvelleOrigine.getY()));
    positionPrecendenteCurseur = positionCurseur;
}
Also used : Vector2D(org.apache.commons.math3.geometry.euclidean.twod.Vector2D)

Example 2 with Vector2D

use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.

the class Aire method abscisses.

/**
 * Récupère l'ensemble des abscisses des points dans leur séquence.
 *
 * @return les abscisses de points.
 */
private static double[] abscisses(@NotNull final Vector2D[] points) {
    final double[] abscisses = new double[points.length];
    int i = 0;
    for (final Vector2D point : points) {
        abscisses[i] = point.getX();
        i++;
    }
    return abscisses;
}
Also used : Vector2D(org.apache.commons.math3.geometry.euclidean.twod.Vector2D)

Example 3 with Vector2D

use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.

the class Aire method distance.

@Override
public double distance(@NotNull final Vector2D curseur, @NotNull final Repere repere) {
    if (positionDansAire(curseur, repere)) {
        return 0;
    }
    Vector2D premierPoint = null;
    Vector2D point1 = null;
    Vector2D point2;
    double distance = Double.MAX_VALUE;
    int i = 0;
    final Iterator<ObjectProperty<Vector2D>> iteration = points.iterator();
    while (i < points.size()) {
        if (i == 0) {
            point1 = repere.positionVirtuelle(iteration.next().getValue());
            premierPoint = point1;
        }
        i++;
        if (i < points.size()) {
            point2 = repere.positionVirtuelle(iteration.next().getValue());
        } else {
            point2 = premierPoint;
        }
        distance = Math.min(distance, new Segment(point1, point2, null).distance(curseur));
        point1 = point2;
    }
    return distance;
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) Vector2D(org.apache.commons.math3.geometry.euclidean.twod.Vector2D) Segment(org.apache.commons.math3.geometry.euclidean.twod.Segment)

Example 4 with Vector2D

use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.

the class AxeHorizontal method dessiner.

@Override
public void dessiner(@NotNull final Canvas toile, @NotNull final Repere repere) {
    final double[] graduationsVerticales = repere.graduationsVerticales(toile.getWidth(), getEspacement());
    final double[] abscissesReelles = repere.abscissesReelles(graduationsVerticales);
    actualiserEtiquettes(abscissesReelles, formatValeurs(repere));
    final double positionReelleAxe = positionReelleAxe(toile, repere);
    fleche.setOrigine(new Vector2D(repere.abscisseReelle(0), positionReelleAxe));
    fleche.setArrivee(new Vector2D(repere.abscisseReelle(toile.getWidth()), positionReelleAxe));
    dessinerGraduations(toile, graduationsVerticales, positionVirtuelleAxe(toile, repere));
    fleche.dessiner(toile, repere);
    actualiserPositionEtiquettes(toile, repere);
    etiquettes.values().forEach((etiquette) -> {
        etiquette.dessiner(toile, repere);
    });
}
Also used : Vector2D(org.apache.commons.math3.geometry.euclidean.twod.Vector2D)

Example 5 with Vector2D

use of org.apache.commons.math3.geometry.euclidean.twod.Vector2D in project graphysica by Graphysica.

the class AxeHorizontal method actualiserPositionEtiquettes.

/**
 * Actualise la position des étiquettes de cet axe.
 *
 * @param toile la toile affichant cet axe.
 * @param repere le repère de l'espace à graduer.
 */
private void actualiserPositionEtiquettes(@NotNull final Canvas toile, @NotNull final Repere repere) {
    final double ordonneeReelleAxe = positionReelleAxe(toile, repere);
    positionVirtuelle = positionVirtuelleAxe(toile, repere);
    final Iterator<Map.Entry<Double, Etiquette>> iteration = etiquettes.entrySet().iterator();
    while (iteration.hasNext()) {
        final Map.Entry<Double, Etiquette> entree = iteration.next();
        final double valeur = entree.getKey();
        final Etiquette etiquette = entree.getValue();
        etiquette.setPositionAncrage(new Vector2D(valeur, ordonneeReelleAxe));
        if (positionVirtuelle >= toile.getHeight() - etiquette.getHauteur()) {
            etiquette.setPositionRelative(new Vector2D(-etiquette.getLargeur() / 2, toile.getHeight() - positionVirtuelle - etiquette.getHauteur()));
        } else {
            etiquette.setPositionRelative(new Vector2D(-etiquette.getLargeur() / 2, 0));
        }
    }
}
Also used : Vector2D(org.apache.commons.math3.geometry.euclidean.twod.Vector2D) Map(java.util.Map)

Aggregations

Vector2D (org.apache.commons.math3.geometry.euclidean.twod.Vector2D)26 Map (java.util.Map)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)4 List (java.util.List)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Point2d (javax.vecmath.Point2d)4 Point3d (javax.vecmath.Point3d)4 Tweed (org.twak.tweed.Tweed)4 TweedSettings (org.twak.tweed.TweedSettings)4 Line (org.twak.utils.Line)4 Material (com.jme3.material.Material)3 ColorRGBA (com.jme3.math.ColorRGBA)3 Geometry (com.jme3.scene.Geometry)3 Mesh (com.jme3.scene.Mesh)3 Node (com.jme3.scene.Node)3 VertexBuffer (com.jme3.scene.VertexBuffer)3 Collections (java.util.Collections)3 Comparator (java.util.Comparator)3