Java Code Examples for org.apache.commons.math3.geometry.euclidean.twod.Line#intersection()

The following examples show how to use org.apache.commons.math3.geometry.euclidean.twod.Line#intersection() . 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: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2), 1.0e-10);
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1), 1.0e-10);
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 2
Source File: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2));
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1));
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 3
Source File: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2));
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1));
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 4
Source File: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2));
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1));
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 5
Source File: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2));
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1));
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 6
Source File: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2));
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1));
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 7
Source File: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2));
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1));
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 8
Source File: LineTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testIntersection() {
    Line    l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2), 1.0e-10);
    Line    l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1), 1.0e-10);
    Vector2D p  = l1.intersection(l2);
    Assert.assertEquals(0.5, p.getX(), 1.0e-10);
    Assert.assertEquals(1.5, p.getY(), 1.0e-10);
}
 
Example 9
Source File: GeometryUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenLineIntersection_thenCorrect() {
    Line l1 = new Line(new Vector2D(0, 0), new Vector2D(1, 1), 0);
    Line l2 = new Line(new Vector2D(0, 1), new Vector2D(1, 1.5), 0);

    Vector2D intersection = l1.intersection(l2);

    Assert.assertEquals(2, intersection.getX(), 1e-7);
    Assert.assertEquals(2, intersection.getY(), 1e-7);
}
 
Example 10
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private double intersectionAbscissa(Line l0, Line l1) {
    Vector2D p = l0.intersection(l1);
    return (l0.toSubSpace(p)).getX();
}
 
Example 11
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private double intersectionAbscissa(Line l0, Line l1) {
    Vector2D p = l0.intersection(l1);
    return (l0.toSubSpace(p)).getX();
}
 
Example 12
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private double intersectionAbscissa(Line l0, Line l1) {
    Vector2D p = l0.intersection(l1);
    return (l0.toSubSpace(p)).getX();
}