Range penalty for guns - range

I'd like to know if anyone has a formula for range penalty that takes into account that the horizontal inaccuracy involves straight trig but the vertical inaccuracy involves ballistic inaccuracy ( calculating for the falloff effects of gravity) AND trig.

Related

How to make projectile travel with a curve trajectory to a targeted position in 3D

So I want to have my projectiles travel to a targeted position with in a certain amount of time and have a curve trajectory with a max height. I have watchh a couple youtube tutorials but they're just simply not want I need right now is there a way for me to do this ?
I followed this tutorial as first but I can't increase the speed and reduce the time and the height to my liking:
https://www.youtube.com/watch?v=Qxs3GrhcZI8
You have a targeted position implies that the distance between the user and the target is r (say). Now, you want the projectile to hit the target in a certain time t. Let's say the projectile was thrown at a velocity v. Below are the calculations that yield the result of how much velocity and angle of projection are required to achieve the hit in the given time t
The question says
have a curve trajectory with a max height.
Theoretically, the maximum height is achieved when the angle of projection is 90 degrees with respect to the ground and the cosine of 90 is 0. Substituting the value of cos(theta) in the resultant equation results in the value of velocity being infinity, which is practically impossible.
Hence, with the given range and time of flight, two variables, the velocity, and angle of projection can be configured. If the maximum height that you want to achieve is specified, the angle of projection is calculated accordingly.
Unity Slerp will be a good fit for you. You can specify the start, end point and also
control the time. You won't be able to control the height as its dependent on the Vectors.
Here is the Link to Unity Docs
https://docs.unity3d.com/ScriptReference/Vector3.Slerp.html

Usage of gradient in the updation of weight and bias in neural network

Why do we use the gradient of the loss function to update the weight and bias of a neural network?
for example:
new_weight = old_weight - learning_rate * gradient
In other words how does gradient help us in updating the weight and bias correctly.
This is a gross simplification: the gradient is multidimensional derivate compacted into a "single structure". The derivate tells you, where the is a local change.
The gradient, tells you where there are local changes in all the dimensions you are considering.
Consider the 3-Dimensional case: our world. Image you are climbing a hill. Suppose your sight is limited at 3 meters for your position. Your goal is to reach the top.
You start from a point, and you look around. As you see 3 meters from your position in your direction, you choose to go where you see that the slope is steeper.
The action of looking around is computing the gradient and correcting your speed.
In your equation, remember this is a gross example, you are saying "Uhm, the first time I checked my direction was 124 degrees, now, looking at the gradient my direction should be 10 degrees. Which direction should I take now".
The learning rate or your equation is a coefficient that you can interpret as "friction", or "trust": you don't want to change your direction of 114 degres in one shot, instead you want to change with respect to the magnitude of the new measure.
You detect that the new direction should be 114 degrees (124-10) less the current one. So, if your learning rate is low, your new direction will impact less than in the case when the learning rate is higher.
This example gets generalized on multiple dimensions.

How to measure floor area using ARCore?

I'm a beginner, take it easy on me.
How would you measure the area of the floor using ARCore/Unity. I figure you somehow measure the area of the plane visualiser, or measure the area of each individual triangle, but I have no idea how to attack it.
The closest thing I can find is measuring distance...
You can get a (somewhat imprecise) estimate by multiplying
plane.getExtentX() * plane.getExtentZ();
This is most likely too high because it assumes the plane to be rectangular and
will suffer from measurement errors in both directions. But it might be good enough depending on your usecase.
A slightly more precise alternative would be to get the plane's polygon
plane.getPolygon()
and then computing the polygon's area

How do I calculate acceleration/deceleration in the direction of travel from X,Y,Z accelerometer readings from iphone

I am writing an iPhone/iPad app. I need to compute the acceleration and deceleration in the direction of travel of a vehicle traveling in close to a straight horizontal line with erratic acceleration and deceleration. I have the sequence of 3 readings from the X,Y,Z orthogonal accelerometers. But the orientation of the iphone/ipad is arbitrary and the accelerometer readings include vehicle motion and the effect of gravity. The result should be a sequence of single acceleration values which are positive or negative depending on whether the vehicle is decelerating or accelerating. The positive and negative direction is arbitrary so long as acceleration has the opposite sign to deceleration. Gravity should be factored out of the result. Some amount of variable smoothing of the result would be useful.
The solution should be as simple as possible and must be computationally efficient. The answer should be some kind of pseudo-code algorithm, C code or a sequence of equations which could easily be converted to C code. An iPhone specific solution in Objective C would be fine too.
Thanks
You will need some trigonometry for this, for example to get the magnitude you need
magn = sqrt(x*x+y*y+z*z);
to get the angle you will need atan, then c function atan2 is better
xyangel = atan2(y,x);
xymagn = sqrt(x*x+y*y);
vertangle = atan2(z,xymagn)
no how you get negative and positive magnitude is arbitrary, you could for example interpret π/2 < xyangle < 3π/2 as negative. That would be taking the sign of x for the sign of magn, but it would be equally valid to take the sign from y
It is really tough to separate gravity and motion. It's easier if you can analyze the data together with a gyroscope and compass signal.
The gyroscope measures the rate of angular rotation. Its integral is theoretically the angular orientation (plus an unknown constant), but the integral is subject to drift, so is useless on its own. The accelerometer measures angular orientation plus gravity plus linear acceleration. With some moderately complex math, you can isolate all 3 of those quantities from the 2 sensors' values. Adding the compass fixes the XY plane (where Z is gravity) to an absolute coordinate frame.
See this great presentation.
Use userAcceleration.
You don't have to figure out how to remove gravity from the accelerometer readings and how to take into accont the orientation: It is already implemeted in the Core Motion Framework.
Track the mean value of acceleration. That will give you a reference for "down". Then subtract the mean from individual readings.
You'll need to play around with the sensitivity of the mean calculation, since, e.g., making a long slow turn on a freeway will cause the mean to slowly drift outwards.
If you wanted to compensate for this, you could use GPS tracking to compute a coarse-grained global acceleration to calibrate the accelerometer. In fact, you might find that differentiating the GPS velocity reading gives a good enough absolute acceleration all by itself (I haven't tried, so I can't say).

How can the friction drag be calculated for a moving and spinning disk on a 2D surface?

Let's consider a disk with mass m and radius R on a surface where friction u also involved. When we give this disk a starting velocity v in a direction, the disk will go towards that direction and slow down and stop.
In case the disk has a rotation (or spin with the rotational line perpendicular on the surface) w beside the speed then the disk won't move on a line, instead bend. Both the linear and angular velocity would be 0 at the end.
How can this banding/curving/dragging be calculated? Is it possible to give analytical solution for the X(v,w,t) function, where X would give the position of the disk according to it's initial v w at a given t?
Any simulation hint would be also fine.
I imagine, depending on w and m and u there would be an additional velocity which is perpendicular to the linear velocity and so the disk's path would bend from the linear path.
If you're going to simulate this, I'd probably recommend something like dividing up the contact surface between the disk and the table into a radial grid. Compute the relative velocity and the force at each point on the grid at each time step, then sum up the forces and torques (r cross F) to get the net force F and the net torque T on the disk as a whole. Then you can apply the equations F=(m)(dv/dt) and T=(I)(dw/dt) to determine the differential changes in v and w for the next time step.
For what it's worth, I don't think a flat disk would curve under the influence of either a frictional force (velocity-independent) or a drag force (linearly proportional to velocity).
A ball will move in a large arc with spin, but a [uniform] disk on a 2D surface will not.
For the disk it's center of spin is the same as it's center of gravity, so there is no torque applied. (As mentioned by duffymo, a nonuniform disk will have a torque applied.)
For a uniform ball, if the axis of the spin is not perpendicular to the table, this causes the ball to experience a rotational torque which causes it to move in a slight arc. The arc has a large radius, and the torque is slight, so usually friction makes the ball stop quickly.
If there was a sideways velocity, the ball would move along a parabola, like a falling object. The torque component (and the radius of the arc) can be computed in the same way you do for a precessing top. It's just that the ball sits at the tip of the top (err....) and the bottom is "imaginary".
Top equation: http://hyperphysics.phy-astr.gsu.edu/HBASE/top.html
omega_p = mgr/I/omega
where
omega_p = rotational velocity...dependent on how quickly you want friction to slow the ball
m = ball mass
g = 9.8 m/s^2 (constant)
r = distance from c.g. (center of ball) to center, depends on angle of spin axis (solve for this)
omega = spin rate of ball
I = rotational inertia of a sphere
My 2 cents.
Numerical integration of Newton's laws of motion would be what I'd recommend. Draw the free body diagram of the disk, give the initial conditions for the system, and numerically integrate the equations for acceleration and velocity forward in time. You have three degrees of freedom: x, y translation in the plane and the rotation perpendicular to the plane. So you'll have six simultaneous ODEs to solve: rates of change of linear and angular velocities, rates of change for two positions, and the rate of change of angular rotation.
Be warned: friction and contact make that boundary condition between the disk and the table non-linear. It's not a trivial problem.
There could be some simplifications by treating the disk as a point mass. I'd recommend looking at Kane's Dynamics for a good understanding of the physics and how to best formulate the problem.
I'm wondering if the bending of the path that you're imagining would occur with a perfectly balanced disk. I haven't worked it out, so I'm not certain. But if you took a perfectly balanced disk and spun it about its center there'd be no translation without an imbalance, because there's no net force to cause it to translate. Adding in an initial velocity in a given direction wouldn't change that.
But it's easy to see a force that would cause the disk to deviate from the straight path if there was an imbalance in the disk. If I'm correct, you'll have to add an imbalance to your disk to see bending from a straight line. Perhaps someone who's a better physicist than me could weigh in.
When you say friction u, I'm not sure what you mean. Usually there is a coefficient of friction C, such that the friction F of a sliding object = C * contact force.
The disk is modeled as a single object consisting of some number of points arranged in circles about the center.
For simplicity, you might model the disk as a hexagon evenly filled with points, to make sure every point represents equal area.
The weight w of each point is the weight of the portion of the disk that it represents.
It's velocity vector is easily computed from the velocity and rotation rate of the disk.
The drag force at that point is minus its weight times the coefficient of friction, times a unit vector in the direction of its velocity.
If the velocity of a point becomes zero, its drag vector is also zero.
You will probably need to use a tolerance about zero, else it might keep jiggling.
To get the total deceleration force on the disk, sum those drag vectors.
To get the angular deceleration moment, convert each drag vector to an angular moment about the center of the disk, and sum those.
Factor in the mass of the disk and angular inertia, then that should give linear and angular acclerations.
For integrating the equations of motion, make sure your solver can handle abrupt transitions, like when the disk stops.
A simple Euler solver with really fine stepsize might be good enough.