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

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

Introduction

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

Prototype

public Vector2D(double a, Vector2D u) 

Source Link

Document

Multiplicative constructor Build a vector from another one and a scale factor.

Usage

From source file:org.evors.core.TestUtils.java

public static Matcher<Vector2D> vEquals(double x, double y) {
    return vEquals(new Vector2D(x, y));
}

From source file:org.evors.core.TestUtils.java

public static void assertTwoVector2DsEqual(float x, float y, Vector2D v2, boolean assertion) {
    assertTwoVector2DsEqual(new Vector2D(x, y), v2, assertion);
}

From source file:org.evors.core.TestUtils.java

@Test
public void vectorsShouldBeEqual() {
    Vector2D v1 = new Vector2D(2, 2);
    Vector2D v2 = new Vector2D(2, 2);
    assertTwoVector2DsEqual(v1, v2, true);
}

From source file:org.evors.core.TestUtils.java

@Test
public void vectorsShouldntBeEqual() {
    Vector2D v1 = new Vector2D(2, 2);
    Vector2D v2 = new Vector2D(3, 2);
    assertTwoVector2DsEqual(v1, v2, false);
}

From source file:org.evors.core.util.geometry.IntersectionTest.java

@Test
public void linesIntersectAt1_1() {
    assertEquals(new Vector2D(1, 1), interAt1_1A.getIntersection(interAt1_1B).intersectionPoint);
}

From source file:org.evors.core.util.geometry.IntersectionTest.java

@Test
public void linesIntersectAt4_4() {
    assertEquals(new Vector2D(4, 4), interAt4_4A.getIntersection(interAt4_4B).intersectionPoint);
}

From source file:org.evors.core.util.geometry.IntersectionTest.java

@Test
public void line2TangentPointIs2_0() {
    Line circLine2 = Line.fromCoords(2, -4, 2, 4);
    assertThat(new Vector2D(2, 0), vEquals(Intersection.CircleLine.calculate(circle, circLine2).intersectp1));
}

From source file:org.evors.core.util.geometry.IntersectionTest.java

@Test
public void line1IntersectionPointsAre0_n2__0_2() {
    Line circLine1 = Line.fromCoords(0, -4, 0, 4);
    Intersection.CircleLine icl = Intersection.CircleLine.calculate(circle, circLine1);
    assertThat(icl.intersectp1, vEquals(new Vector2D(0, 2)));
    assertThat(icl.intersectp2, vEquals(new Vector2D(0, -2)));
}

From source file:org.evors.core.util.geometry.IntersectionTest.java

@Test
public void circleAndLineDoNotIntersect() {
    //Reproducing a bug
    circle = Circle.getFromCenter(new Vector2D(0.3467132624, 0.0035458654), 0.065);
    Line line = Line.fromCoords(-1.2, -1.2, -0.8, -1.2);
    assertFalse(circle.intersectsWith(line));
}

From source file:org.evors.core.util.geometry.IntersectionTest.java

@Test
public void circleAndLineDoNotIntersect2() {
    //Reproducing a bug
    circle = Circle.getFromCenter(new Vector2D(0.3396085131, -0.0168142506), 0.065);
    Line line = Line.fromCoords(0.8, 0.8, 1.2, 0.8);
    assertFalse(circle.intersectsWith(line));
}