Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculateDrag() method physics3d implementation #99

Merged
merged 6 commits into from
Jun 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions app/src/main/java/src/land/LandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

public class LandingController
{
private final double LANDER_AREA = 100; // TODO (CAN) get real value for Mars Lander
private final double DRAG_COEFICIENT = 1; //TODO (CAN) get value
private final double LANDER_AREA = 1.91; // Mars InSight lander was 1.56 meters in diameter, pi * radius^2
private final double DRAG_COEFFICIENT = 2.1; // page 1187, from https://pdfs.semanticscholar.org/5410/30f5b4c387a3d5d06fbee8549347d6bddf82.pdf
private final double AIR_DENSITY = 5.428; // https://www.aero.psu.edu/avia/pubs/LanSch17.pdf, page 3

public LandingController()
{
Expand Down Expand Up @@ -88,12 +89,22 @@ public Vector3d removeZDimension(Vector3d v)
}

/**
* @param a velocity vector which is used to calculate drag from
* @return the force of drag exerted at the current velocity using the final values declared
* in the class
*
* Implementing Fd = Cd * rho * V^2 * Area * 1/2 * unitVector
* Represents (respectively): Force of drag = dragCoefficient * airDensity * magnitudeOfVelocity^2 * 1/2 * unitVector
*/
protected Vector3d calculateDrag(Vector3d velocity)
{
// TODO (Can) 2hrs
return new Vector3d();
Vector3d unitVector = velocity.unitVector();
Vector3d vectorDirection = unitVector.mul(-1); //drag acts in the opposite direction in relation to the velocity.

double veloMagnitude = velocity.norm();
double constant = DRAG_COEFFICIENT * LANDER_AREA * AIR_DENSITY * veloMagnitude * veloMagnitude * 0.5;

Vector3d dragForce = vectorDirection.mul(constant); //scale the unit vector by the constants we have, to get the actual drag force vector
return dragForce;
}
}