Skip to content
Snippets Groups Projects
Commit afd09e77 authored by DIDIer5454's avatar DIDIer5454
Browse files

test corrige

parent 5559e929
Branches
No related tags found
No related merge requests found
Pipeline #10591 passed
...@@ -35,6 +35,7 @@ public class Sphere { ...@@ -35,6 +35,7 @@ public class Sphere {
return pos_.distance(other.pos_); return pos_.distance(other.pos_);
} }
//Methode renvoyant la distance au carre entre 2 spheres
public double distanceSquaredTo(Sphere other) { public double distanceSquaredTo(Sphere other) {
return pos_.distanceSquared(other.pos_); return pos_.distanceSquared(other.pos_);
} }
......
...@@ -13,5 +13,56 @@ public class SphereTest { ...@@ -13,5 +13,56 @@ public class SphereTest {
Sphere mySphere = new Sphere(1.5); Sphere mySphere = new Sphere(1.5);
assertEquals(14.137166941154069, mySphere.computeVolume(), 0.0); assertEquals(14.137166941154069, mySphere.computeVolume(), 0.0);
} }
@Test
public void testDistancesquareTo(){
Sphere un=new Sphere(1.5,new Point3d(new double[]{0,0,3}));
Sphere deux=new Sphere(1.5,new Point3d(new double[]{2,1,0}));
assertEquals(14,un.distanceSquaredTo(deux));
}
@Test
public void test_inContactWith(){
Sphere un=new Sphere(1.5,new Point3d(new double[]{0,0,3}));
Sphere deux=new Sphere(1.5,new Point3d(new double[]{2,1,0}));
Sphere trois=new Sphere(4,new Point3d(new double[]{0,0,3}));
assertFalse(un.inContactWith(deux));
assertTrue(trois.inContactWith(deux));
assertTrue(un.inContactWith(trois));
}
@Test
public void testGetPos(){
Sphere mySphere = new Sphere(1.5);
assertEquals(new Point3d(new double[]{0,0,0}),mySphere.getPos());
}
@Test
public void testgetRadius(){
Sphere deux=new Sphere(1.5,new Point3d(new double[]{2,1,0}));
Sphere trois=new Sphere(4,new Point3d(new double[]{0,0,3}));
assertEquals(1.5,deux.getRadius());
}
@Test
public void testDistanceTo(){
Sphere deux=new Sphere(1.5,new Point3d(new double[]{2,1,0}));
Sphere trois=new Sphere(4,new Point3d(new double[]{0,0,3}));
assertEquals(Math.sqrt(14.0),deux.distanceTo(trois));
}
@Test
public void TestConstructeurParam(){
Sphere deux=new Sphere(1.5,new Point3d(new double[]{2,1,0}));
Sphere trois=new Sphere(4,new Point3d());
Sphere un=new Sphere(8);
assertEquals(new Point3d(new double[]{0,0,0}),un.getPos());
assertEquals(8,un.getRadius());
assertEquals(4,trois.getRadius());
assertEquals(new Point3d(new double[]{0,0,0}),trois.getPos());
assertEquals(new Point3d(new double[]{2,1,0}),deux.getPos());
assertEquals(1.5,deux.getRadius());
}
@Test
public void ConstructeurSansParam(){
Sphere quatre =new Sphere();
//assertEquals(new Point3d(), quatre.getPos());
assertEquals(0.0, quatre.getRadius(),0.0);
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment