Vector2D extends Vecteur { public boolean isColinear(Vector2D vect) { if (vect.getX() * this.getY() == vect.getY() * this.getX()) return true; return false; } Vector2D(double x, double y);  Vector2D();  Vector2D(IDirectPosition dp1, IDirectPosition dp2);  Vector2D(IDirectPosition dp1);  Vector2D(Angle angle, double norm); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); Vector2D add(Vector2D v); @Override Vecteur ajoute(Vecteur v1); Vector2D copy(); void scalarMultiplication(double lambda); @Override ILineString translate(ILineString l); double vectorAngle(Vector2D v); double vectorAngle0ToPi(Vector2D v); boolean isNull(); Vector2D changeNorm(double newNorm); Vector2D rotate(double angle); Vector2D opposite(); ILineSegment toGeom(IDirectPosition point); boolean isColinear(Vector2D vect); boolean isColinear(Vector2D vect, double tolerance); Vector2D project(double direction);  }
@Test public void testIsColinear() { IDirectPosition p1 = new DirectPosition(0.0, 0.0); IDirectPosition p2 = new DirectPosition(0.0, 10.0); IDirectPosition p3 = new DirectPosition(10.0, 0.0); IDirectPosition p4 = new DirectPosition(0.0, 5.0); IDirectPosition p5 = new DirectPosition(5.0, 0.0); Vector2D vect1 = new Vector2D(p1, p2); Vector2D vect2 = new Vector2D(p1, p3); Vector2D vect3 = new Vector2D(p1, p4); Vector2D vect4 = new Vector2D(p1, p5); Vector2D vect5 = new Vector2D(p5, p1); Assert.assertTrue(vect1.isColinear(vect3)); Assert.assertTrue(vect2.isColinear(vect4)); Assert.assertTrue(vect5.isColinear(vect2)); }