0
\$\begingroup\$

On the Bombsight Wikipedia page, I get that equation. I do not understand it very well. How would I go about writing that in C#? The drag doesn't matter in my project. It's not a flight sim. I know that the angle of the camera/sight is a non linear function of the speed and altitude of the aircraft. Any pointers would be greatly appreciated. Was this the correct stack to post this question in, or was the physics stack a better option?

\$\endgroup\$
5
  • \$\begingroup\$ As stated in the article, those formulas are for computing the vertical and horizontal components of the drag. Why are you converting drag calculations to C# if you're not taking drag into account? \$\endgroup\$ – Pikalek Jun 20 at 3:14
  • \$\begingroup\$ @Pikalek I thought that only certain parts of the equation were dealing with drag. Not the whole thing. Thank you for clearing that up. Would you have an idea of where I can find a C# equation for that or how I could write the equation myself? \$\endgroup\$ – Privvet Jun 20 at 5:20
  • \$\begingroup\$ I've posted a translation as requested, however I want to restate that without context, it's not clear if this helpful to your larger goal. The formulas on Wikipedia represent the physics of reality. If your project is modelling those aspects of reality, it make sense to consider them, but if your project doesn't, then they won't make sense. If your drag is zero, then these formulas reduce to zero & there's no point in calculating them. It might be more helpful to directly state the problem you are trying to solve with these formulas. \$\endgroup\$ – Pikalek Jun 20 at 17:43
  • \$\begingroup\$ @Pikalek sorry for such a late reply. I'm trying to write a script that angles a camera based on velocity and altitude to make a device that makes dropping payloads easier. Like a bomb sight. The only problem is that I don't know what equation to use with the altitude and velocity values so I can get an accurate angle value. And no. There will be no drag in my project. \$\endgroup\$ – Privvet Jun 27 at 9:29
  • \$\begingroup\$ In that case you should edit your question to include information about what you are modelling in your game. Is the terrain flat or does it have varied elevation? Does it curve like the earth? Like drag, there's a lot of factors that could come into play, but we need to know more about the situation. It might also help to know, what happens right now if you simply sight straight down from the plane? Even if that doesn't produce the desired result, it gives a starting point. \$\endgroup\$ – Pikalek Jun 28 at 13:34
0
\$\begingroup\$

The formulas given for vertical & horizontal drag are:

\$ d_v = CAρv_v\sqrt{v^2_v+v^2_h} \\ d_h = CAρv_h\sqrt{v^2_v+v^2_h} \$

where:

  • \$v_v\$ is the vertical component of the velocity
  • \$v_h\$ is the horizontal component of the velocity
  • \$C\$ is the coefficient of drag
  • \$A\$ is the cross-sectional area (of the bomb)
  • \$ρ\$ is the air density

Converting that to code, would give you something like this:

double speed = Math.sqrt(velocityVert * velocityVert  + velocityHrzt * velocityHrzt);
double dragVert = dragCoeff * area * airDensity * velocityVert * speed;
double dragHrzt = dragCoeff * area * airDensity * velocityHrzt * speed;

If your code base is already using vectors, you can replace the drag & velocity variables with vectors components.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.