Skip to content

Commit

Permalink
Merge pull request #100 from group22DKE/testNormalizeandRemovez_physi…
Browse files Browse the repository at this point in the history
…cs3d_impl

Created test cases for normalize and removeZ methods
  • Loading branch information
S010MON authored Jun 18, 2021
2 parents 007be75 + 08ced4f commit 927b2dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/src/land/LandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected boolean impact(Vector3d landerPosition, double radius)
* Normalise the vectors so that a is given relative to b where b = (0,0,0)
* @return a vector a relative to b
*/
protected Vector3d normalise(Vector3d a, Vector3d b)
public Vector3d normalise(Vector3d a, Vector3d b)
{
double x = a.getX() - b.getX();
double y = a.getY() - b.getY();
Expand All @@ -80,7 +80,7 @@ protected Vector3d normalise(Vector3d a, Vector3d b)
/**
* @return a new Vector3d object with x and y copied and a 0 value for z
*/
protected Vector3d removeZDimension(Vector3d v)
public Vector3d removeZDimension(Vector3d v)
{
double x = v.getX();
double y = v.getY();
Expand Down
19 changes: 18 additions & 1 deletion app/src/test/java/src/test/TestLandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,31 @@ void testOnlyLanderFall()
// TODO (Sam) 2hrs
}

@Test void testNormalise()
@Test void testNormaliseOneNegativeOnePosiive()
{
// TODO (Alp) 1hr
LandingController control = new LandingController();
assertEquals(control.normalise(new Vector3d(4,4,4),new Vector3d(-1,-2,-3)),new Vector3d(5,6,7));
}

@Test void testRemoveZDimension()
{
// TODO (Alp) 30
LandingController control = new LandingController();
assertEquals(control.removeZDimension(new Vector3d(4,4,4)), new Vector3d(4,4,0));

}

@Test void testNormaliseTwoNegative()
{
LandingController control = new LandingController();
assertEquals(control.normalise(new Vector3d(-40,-91,-43),new Vector3d(-100,-40,-33)),new Vector3d(60,-51,-10));
}

@Test void testNormaliseTwoPositive()
{
LandingController control = new LandingController();
assertEquals(control.normalise(new Vector3d(100,94,45),new Vector3d(213,432,113)),new Vector3d(-113,-338,-68));
}

}

0 comments on commit 927b2dc

Please sign in to comment.