Skip to content

Commit

Permalink
Merge pull request #115 from group22DKE/air_pressure_scaling
Browse files Browse the repository at this point in the history
Created method which returns a scaled version of air pressure at point.
  • Loading branch information
S010MON authored Jun 21, 2021
2 parents 5d45927 + b8e485e commit 807d4b5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/src/main/java/src/land/LandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,21 @@ else if (height>=50000 && height<200000) {
return randValue;
}
}

public double airPressureScaling(Vector3d point, double radius) {

double atmosphereMaxRange = 600000;
double originToPoint = point.dist(new Vector3d());
double realDistance = originToPoint - radius;

if (realDistance>=atmosphereMaxRange) {
return 0;
}
else if (-radius<realDistance && realDistance<=0) { //touching or inside the planet
return airPresSeaLevel;
}

double scaleOfDistance = realDistance/atmosphereMaxRange;
return scaleOfDistance*airPresSeaLevel;
}
}
31 changes: 31 additions & 0 deletions app/src/test/java/src/test/TestLandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,35 @@ void logBallFallFromOrbit()
System.out.println(control.airPressureAt(position));
}


/*
* Partitions:
* Out of the atmosphere's range
* In the atmoshpere's range
* Touching the radius
* On/inside the planet
*/
@Test void testAirPresScalingAboveMax() {
LandingController control = new LandingController();
Vector3d position = new Vector3d(0,2e25,0);
System.out.println(control.airPressureScaling(position,1000));
}

@Test void testAirPresScalingZero() {
LandingController control = new LandingController();
Vector3d position = new Vector3d(0,10,0);
System.out.println(control.airPressureScaling(position,10));
}

@Test void testAirPresScalingBelowZero() {
LandingController control = new LandingController();
Vector3d position = new Vector3d(0,9,0);
System.out.println(control.airPressureScaling(position,10));
}

@Test void testAirPresScalingHalfway() {
LandingController control = new LandingController();
Vector3d position = new Vector3d(0,500000,0);
System.out.println(control.airPressureScaling(position,200000));
}
}

0 comments on commit 807d4b5

Please sign in to comment.