Example usage for org.apache.commons.math3.geometry.euclidean.twod Segment Segment

List of usage examples for org.apache.commons.math3.geometry.euclidean.twod Segment Segment

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.euclidean.twod Segment Segment.

Prototype

public Segment(final Vector2D start, final Vector2D end, final Line line) 

Source Link

Document

Build a segment.

Usage

From source file:eu.mihosoft.vrl.workflow.fx.MathTest.java

public static void main(String[] args) {
    Vector2D p1 = new Vector2D(-1, 0);
    Vector2D p2 = new Vector2D(1, 0);

    Vector2D p3 = new Vector2D(0, -1);
    Vector2D p4 = new Vector2D(0, 1);

    Line l1 = new Line(p1, p2, 1e-5);

    Line l2 = new Line(p3, p4, 1e-5);

    Segment s1 = new Segment(p2, p1, l1);
    Segment s2 = new Segment(p4, p3, l2);

    Vector2D lIntersection = l1.intersection(l2);
    Vector2D sIntersection = new SubLine(s1).intersection(new SubLine(s2), true);

    System.out.println("l-intersection: " + lIntersection);
    System.out.println("s-intersection: " + sIntersection);

}