Skip to content

Instantly share code, notes, and snippets.

@paytonrules
Created November 9, 2012 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paytonrules/4047354 to your computer and use it in GitHub Desktop.
Save paytonrules/4047354 to your computer and use it in GitHub Desktop.
657 void callback() {
658 // Lift = R(0, 1, 0) |K| (sin theta)
659 // Drag = -K (sin theta)
660 // Where theta is the angle between w (planes direction) and K
661 // This should be direction of - not velocity -
662 // You've got velocity * R (the rotation) u = R(velocity)
663 // K ends up as the actual direction of motion
664 // plane->K + plane->R * Vector(0, 0, +1) Add a constant
665 if (engineSpeed != 0) {
666 // Apply Thrust
667 Vector thrust = plane->R * Vector(0, 0, engineSpeed);
668 plane->K = plane->K + thrust;
669
670 // Apply Lift - Should lift be a force generator?
671 Vector unitThrust = thrust / norm(thrust);
672 float normK = norm(plane->K);
673 Vector unitK = plane->K / normK;
674 cout << "Unit K: " << unitK(X) << "," << unitK(Y) << "," << unitK(Z) << endl;
675 cout << "Unit Thrust: " << unitThrust(X) << "," << unitThrust(Y) << "," << unitThrust(Z) << endl;
676
677 float sinTheta = norm(cross(unitThrust, unitK));
678 Vector lift = plane->R * Vector(0, 1, 0) * normK * sinTheta;
679
680 plane->K = plane->K + lift;
681
682 // Apply Drag
683 // plane->K = plane->K - (plane->K * sinTheta);
684 }
685 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment