Java Code Examples for org.apache.commons.math3.geometry.euclidean.twod.Vector2D#toArray()

The following examples show how to use org.apache.commons.math3.geometry.euclidean.twod.Vector2D#toArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);

    int w = getWidth();
    int h = getHeight();

    g2.clearRect(0, 0, w, h);
    
    g2.setPaint(Color.black);
    g2.drawRect(0, 0, w - 1, h - 1);
    
    for (Vector2D point : points) {
        Vector2D p = transform(point, w, h);
        double[] arr = p.toArray();
        g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
    }
}
 
Example 2
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);

    int w = getWidth();
    int h = getHeight();

    g2.clearRect(0, 0, w, h);
    
    g2.setPaint(Color.black);
    g2.drawRect(0, 0, w - 1, h - 1);
    
    for (Vector2D point : points) {
        Vector2D p = transform(point, w, h);
        double[] arr = p.toArray();
        g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
    }
}
 
Example 3
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);

    int w = getWidth();
    int h = getHeight();

    g2.clearRect(0, 0, w, h);
    
    g2.setPaint(Color.black);
    g2.drawRect(0, 0, w - 1, h - 1);
    
    for (Vector2D point : points) {
        Vector2D p = transform(point, w, h);
        double[] arr = p.toArray();
        g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
    }
}
 
Example 4
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);

    int w = getWidth();
    int h = getHeight();

    g2.clearRect(0, 0, w, h);
    
    g2.setPaint(Color.black);
    g2.drawRect(0, 0, w - 1, h - 1);
    
    for (Vector2D point : points) {
        Vector2D p = transform(point, w, h);
        double[] arr = p.toArray();
        g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
    }
}
 
Example 5
Source File: ClusterAlgorithmComparison.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static List<DoublePoint> normalize(final List<Vector2D> input, double minX, double maxX, double minY, double maxY) {
    double rangeX = maxX - minX;
    double rangeY = maxY - minY;
    List<DoublePoint> points = new ArrayList<DoublePoint>();
    for (Vector2D p : input) {
        double[] arr = p.toArray();
        arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
        arr[1] = (arr[1] - minY) / rangeY * 2 - 1;
        points.add(new DoublePoint(arr));
    }
    return points;
}
 
Example 6
Source File: ClusterAlgorithmComparison.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static List<DoublePoint> normalize(final List<Vector2D> input, double minX, double maxX, double minY, double maxY) {
    double rangeX = maxX - minX;
    double rangeY = maxY - minY;
    List<DoublePoint> points = new ArrayList<DoublePoint>();
    for (Vector2D p : input) {
        double[] arr = p.toArray();
        arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
        arr[1] = (arr[1] - minY) / rangeY * 2 - 1;
        points.add(new DoublePoint(arr));
    }
    return points;
}
 
Example 7
Source File: ClusterAlgorithmComparison.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static List<DoublePoint> normalize(final List<Vector2D> input, double minX, double maxX, double minY, double maxY) {
    double rangeX = maxX - minX;
    double rangeY = maxY - minY;
    List<DoublePoint> points = new ArrayList<DoublePoint>();
    for (Vector2D p : input) {
        double[] arr = p.toArray();
        arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
        arr[1] = (arr[1] - minY) / rangeY * 2 - 1;
        points.add(new DoublePoint(arr));
    }
    return points;
}
 
Example 8
Source File: ClusterAlgorithmComparison.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static List<DoublePoint> normalize(final List<Vector2D> input, double minX, double maxX, double minY, double maxY) {
    double rangeX = maxX - minX;
    double rangeY = maxY - minY;
    List<DoublePoint> points = new ArrayList<DoublePoint>();
    for (Vector2D p : input) {
        double[] arr = p.toArray();
        arr[0] = (arr[0] - minX) / rangeX * 2 - 1;
        arr[1] = (arr[1] - minY) / rangeY * 2 - 1;
        points.add(new DoublePoint(arr));
    }
    return points;
}
 
Example 9
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private Vector2D transform(Vector2D point, int width, int height) {
    double[] arr = point.toArray();
    return new Vector2D(new double[] { PAD + (arr[0] + 1) / 2.0 * (width - 2 * PAD),
                                          height - PAD - (arr[1] + 1) / 2.0 * (height - 2 * PAD) });
}
 
Example 10
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private Vector2D transform(Vector2D point, int width, int height) {
    double[] arr = point.toArray();
    return new Vector2D(new double[] { PAD + (arr[0] + 1) / 2.0 * (width - 2 * PAD),
                                          height - PAD - (arr[1] + 1) / 2.0 * (height - 2 * PAD) });
}
 
Example 11
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private Vector2D transform(Vector2D point, int width, int height) {
    double[] arr = point.toArray();
    return new Vector2D(new double[] { PAD + (arr[0] + 1) / 2.0 * (width - 2 * PAD),
                                          height - PAD - (arr[1] + 1) / 2.0 * (height - 2 * PAD) });
}
 
Example 12
Source File: LowDiscrepancyGeneratorComparison.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private Vector2D transform(Vector2D point, int width, int height) {
    double[] arr = point.toArray();
    return new Vector2D(new double[] { PAD + (arr[0] + 1) / 2.0 * (width - 2 * PAD),
                                          height - PAD - (arr[1] + 1) / 2.0 * (height - 2 * PAD) });
}